FastAPI Integration¶
rabbitkit_lifespan(app: Any = None, *, broker: Any | None = None, rabbit_app: Any | None = None) -> AsyncIterator[None]
async
¶
Async context manager that starts/stops rabbitkit components.
Suitable for use as FastAPI's lifespan parameter or standalone.
Start order: rabbit_app.start_async() → broker.start() / broker.start_async() Stop order (in finally): broker.stop() / broker.stop_async() → rabbit_app.stop_async()
Duck-types sync vs async: if the method is a coroutine, it is awaited.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
Any
|
FastAPI app instance (passed by FastAPI lifespan protocol, may be None). |
None
|
broker
|
Any | None
|
Optional rabbitkit broker (SyncBroker or AsyncBroker). |
None
|
rabbit_app
|
Any | None
|
Optional RabbitApp for lifecycle hooks. |
None
|