Metadata-Version: 2.4
Name: keda_dispatcher
Version: 0.1.0
Summary: 
License: Apache-2.0
License-File: LICENSE
Author: Kevin-Tofu
Author-email: koheitech001@gmail.com
Requires-Python: >=3.10,<3.14
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: boto3 (>=1.42.11,<2.0.0)
Requires-Dist: fastapi (>=0.124.4,<0.125.0)
Requires-Dist: pydantic (>=2.12.5,<3.0.0)
Requires-Dist: python-multipart (>=0.0.21,<0.0.22)
Requires-Dist: redis (>=7.1.0,<8.0.0)
Requires-Dist: uvicorn[standard] (>=0.38.0,<0.39.0)
Description-Content-Type: text/markdown

# keda-dispatcher

Local dev setup with FastAPI/Redis/S3-compatible storage.

## Built-in routes

`create_app` always includes the built-in `/proc` routes (see `keda_dispatcher/api/proc.py`). Passing `extra_routers` just adds more routers on top; it does not remove the defaults.

## Adding external APIs (APIRouter)

Pass routers via CLI (no env needed):

```bash
poetry run keda-dispatcher \
  --extra-router myapp.extra:router \
  --extra-router myapp.health:get_router \
  --host 0.0.0.0 --port 8080
```

- `router_or_factory` can be an `APIRouter` instance or a zero-arg factory returning one.
- `--extra-router` is repeatable; values are passed to `create_app` as `extra_routers`.

### Example: start from an external script `__main__`

Minimal `__main__` that injects extra routers and runs uvicorn:

```python
# myservice/__main__.py
import uvicorn
from keda_dispatcher.settings import Settings
from keda_dispatcher.app_factory import create_app
from myapp.api import router as custom_router
from myapp.health import get_router

def main():
    settings = Settings.from_env()
    extra = [custom_router, get_router()]
    app = create_app(settings, extra_routers=extra)

    uvicorn.run(app, host=settings.host, port=settings.port, reload=settings.reload)

if __name__ == "__main__":
    main()
```

Run:
```bash
python -m myservice
```

### Quick demo

Run:

```bash
bash run_demo.sh
```

Details and code live in `tutorials/external_api.md`, `tutorials/custom_api.py`, `tutorials/health.py`, and `run_demo.sh`.

## CI/CD

- Tests: `.github/workflows/test.yml` (runs on `main` and `dev`, executes `poetry run pytest`)
- Publish: `.github/workflows/publish.yml` (runs on GitHub Releases published event; `poetry publish --build` to PyPI)
- Publishing needs a repo secret `PYPI_API_TOKEN` (a PyPI token like `pypi-AgENd...`)

