pymediate
API Reference

API reference

The public PyMediate types, grouped by dispatch and composition role.

This reference describes PyMediate's public classes, methods, type parameters, attributes, and exceptions. Start with the introduction or quick start if you want a guided request flow.

Requests

APIRole
Request[ResponseT]Declares the response type returned for a request
RequestHandler[RequestT]Handles one request type
Mediator.send()Routes a request and returns its declared response type

Streaming

APIRole
StreamRequest[ChunkT]Declares the type of each streamed chunk
StreamRequestHandler[StreamReqT]Yields chunks for one stream-request type
Mediator.stream()Routes a stream request and returns an iterator

Notifications

APIRole
NotificationBase class for a fact published without a response
NotificationHandler[NotificationT]Handles one notification type; several handlers may subscribe
Mediator.publish()Delivers a notification to its registered subscribers

Request pipelines

APIRole
PipelineBehavior[RequestT]Wraps send() for selected request types
Next[ResponseT]Calls the next behavior or request handler and returns ResponseT

Pipeline behaviors do not wrap stream() or publish().

Service resolution

APIRole
ServicesRegisters service instances during setup
ServiceProviderRead-only protocol used by the mediator for resolution
DependencyInjectorServiceProviderOptional adapter for a Dependency Injector container

Exceptions

The errors reference separates handler validation, dispatch, and service-resolution failures. Most PyMediate validation and dispatch exceptions inherit from PyMediateError; ServiceNotFoundError is separate, subclassing KeyError (a provider is a type-keyed mapping), and raised by service resolution.

Asynchronous and synchronous definitions

The top-level pymediate namespace contains asynchronous mediator, handler, behavior, and Next definitions. pymediate.sync contains their blocking counterparts. Message types, services, service-provider types, and exceptions are shared between the namespaces.

On this page