StreamMessage
faststream.broker.fastapi.route.StreamMessage #
Bases: Request
A class to represent a stream message.
METHOD | DESCRIPTION |
---|---|
__init__ | initializes the StreamMessage object |
get_session | returns a callable function that handles the session of the message |
Initialize a class instance.
PARAMETER | DESCRIPTION |
---|---|
body | The body of the request as a dictionary. |
headers | The headers of the request as a dictionary. TYPE: |
path | The path of the request as a dictionary. TYPE: |
Source code in faststream/broker/fastapi/route.py
close async
#
form #
get_session classmethod
#
get_session(dependant: Dependant, provider_factory: Callable[[], Any]) -> Callable[[StreamMessage[Any]], Awaitable[SendableMessage]]
Creates a session for handling requests.
PARAMETER | DESCRIPTION |
---|---|
dependant | The dependant object representing the session. TYPE: |
provider_factory | Provider factory for dependency overrides. |
RETURNS | DESCRIPTION |
---|---|
Callable[[StreamMessage[Any]], Awaitable[SendableMessage]] | A callable that takes a native message and returns an awaitable sendable message. |
RAISES | DESCRIPTION |
---|---|
AssertionError | If the dependant call is not defined. |
Note
This function is used to create a session for handling requests. It takes a dependant object, which represents the session, and a dependency overrides provider, which allows for overriding dependencies. It returns a callable that takes a native message and returns an awaitable sendable message. The session is created based on the dependant object and the message passed to the callable. The session is then used to call the function obtained from the dependant object, and the result is returned.
Source code in faststream/broker/fastapi/route.py
is_disconnected async
#
is_disconnected() -> bool
Source code in starlette/requests.py
send_push_promise async
#
send_push_promise(path: str) -> None
Source code in starlette/requests.py
stream async
#
stream() -> AsyncGenerator[bytes, None]