Skip to content

Class swarmauri_core.middlewares.IMiddleware.IMiddleware

swarmauri_core.middlewares.IMiddleware.IMiddleware

Bases: ABC

Abstract base class for all middleware implementations.

on_scope abstractmethod async

on_scope(scope)

Hook executed when a new scope is received.

Source code in swarmauri_core/middlewares/IMiddleware.py
45
46
47
@abstractmethod
async def on_scope(self, scope: Scope) -> Scope:
    """Hook executed when a new scope is received."""

on_receive abstractmethod async

on_receive(scope, message)

Hook executed for each message pulled from the receive callable.

Source code in swarmauri_core/middlewares/IMiddleware.py
49
50
51
@abstractmethod
async def on_receive(self, scope: Scope, message: Message) -> Message:
    """Hook executed for each message pulled from the receive callable."""

on_send abstractmethod async

on_send(scope, message)

Hook executed before messages are forwarded to the downstream send.

Source code in swarmauri_core/middlewares/IMiddleware.py
53
54
55
@abstractmethod
async def on_send(self, scope: Scope, message: Message) -> Message:
    """Hook executed before messages are forwarded to the downstream send."""