Request-Response Messaging¶
This package provides a client session with request-response messaging capabilities that can be used to implement application services.
Request-response messaging allows a session to send requests to other sessions. Each receiving session provides a corresponding response, which is returned to the sending session. Each request and response carries an application provided value.
Types of Messages¶
There are three mechanisms to specify the recipient(s) of a message:
-
Send to path: The messages of this type are sent without specifying the receiving session. The server will forward an unaddressed message to any session which was registered as a handler for the path indicated in the message.
-
Send to session: Messages can be sent to a specific session by specifying its ID. To be able to respond to messages addressed to itself, a session still needs to have an internal handler.
-
Send to filter: Messages can also be addressed using a session filter. When receiving such a message, the server will locate all the currently active sessions which match the filter's conditions, and respond to the sender with the number of located sessions; the sender can expect up to that many responses, so it needs to have a handler ready to handle those responses.
diffusion.messaging ¶
Request-response messaging functionality.
ValueType_Bound
module-attribute
¶
ValueType_Bound = typing.Optional[
typing.Union[JsonTypes_Bound, ValueTypeProtocol]
]
The upper bound of all request and response types.
J_In
module-attribute
¶
J_In = TypeVar(
"J_In", bound=ValueType_Bound, contravariant=True
)
A value to be processed by a Callback.
J_Out_MaybeAwaitable
module-attribute
¶
J_Out_MaybeAwaitable = TypeVar(
"J_Out_MaybeAwaitable",
bound=typing.Union[
ValueType_Bound,
typing_extensions.Awaitable[ValueType_Bound],
],
covariant=True,
)
A value to be returned by a Callback.
J_In_contra
module-attribute
¶
J_In_contra = typing_extensions.TypeVar(
"J_In_contra",
bound=ValueType_Bound,
contravariant=True,
default=Any,
)
A value to be processed by a Callback (contravariant).