blackbull.extension¶
blackbull.extension
¶
Extensions register through app.add_extension and public app APIs.
Protocol extensions use the same lifecycle and registration mechanism; do not add a separate protocol-extension base without a shared requirement.
Extension
¶
Bases: ABC
Base class for BlackBull extensions.
Subclasses set extension_key and implement init_app. They
may optionally override startup / shutdown for async
resource lifecycle; BlackBull.add_extension wires those into the
application's app_startup / app_shutdown lifespan events.
add_extension accepts any object exposing init_app(app), so a
duck-typed extension works without adopting this base class.
init_app(app)
abstractmethod
¶
Wire this extension into app (synchronous).
Called by BlackBull.add_extension. Register routes,
middleware, protocol handlers, and event listeners through the public
app.* API, then call _register to store self at
app.extensions[extension_key].
shutdown(app)
async
¶
Async shutdown hook, run at lifespan app_shutdown. Default no-op.
startup(app)
async
¶
Async startup hook, run at lifespan app_startup. Default no-op.