Spakky Mediator
spakky-mediator is the optional in-process domain event consumer and dispatcher provider. spakky-event owns event contracts, publishing, transactional publication and handler-provider validation. Installing event support does not select a local consumer.
Installation and plugin selection
uv add spakky-event spakky-mediator
# Or use the explicit convenience extra:
uv add 'spakky[mediator]'
from spakky.core.application.application import SpakkyApplication
from spakky.core.application.application_context import ApplicationContext
from spakky.core.application.plugin import Plugin
application = SpakkyApplication(ApplicationContext()).load_plugins(include={
Plugin(name="spakky-data"),
Plugin(name="spakky-event"),
Plugin(name="spakky-mediator"),
Plugin(name="spakky-tracing"),
})
This configures plugin loading. Keep the application's transaction provider and other plugins in the include set, register or scan application Pods, then call start(). Calling load_plugins() without an include set loads every installed plugin, including mediator when installed.
Direct dispatch example
This standalone example uses the synchronous mediator without a broker or an application container:
from spakky.core.common.mutability import immutable
from spakky.domain.models.event import AbstractDomainEvent
from spakky.plugins.mediator.mediator import EventMediator
@immutable
class UserCreated(AbstractDomainEvent):
user_id: str
def handle_user_created(event: UserCreated) -> None:
print(f"User created: {event.user_id}")
mediator = EventMediator()
mediator.register(UserCreated, handle_user_created)
mediator.dispatch(UserCreated(user_id="123"))
In an application, load the plugin to register handlers automatically and inject IEventPublisher / IAsyncEventPublisher from spakky.event.event_publisher for type-based routing.
Handler registration
The plugin registers EventMediator, AsyncEventMediator and EventHandlerRegistrationPostProcessor. It registers only AbstractDomainEvent routes. Broker plugins own integration event routes independently, so loading mediator and Kafka together does not require a global IEventConsumer binding.
The role-specific consumer contracts are defined in spakky.event.event_consumer: IDomainEventConsumer and IAsyncDomainEventConsumer for local handlers, and IIntegrationEventConsumer and IAsyncIntegrationEventConsumer for broker handlers. The generic consumer interfaces remain available for existing application ports; applications with both provider categories should request a specific role.
An application declaring a handler without the matching synchronous/asynchronous provider fails startup with EventHandlerProviderUnavailableError. Publishing a domain event without a dispatcher raises DomainEventDispatcherUnavailableError; it never silently drops the event.
Migration
Starting with 9.0.0, install and explicitly select spakky-mediator where local domain dispatch is required. See the 9.0 migration guide for installation extras, startup configuration and provider errors. Update concrete imports:
from spakky.plugins.mediator.mediator import EventMediator, AsyncEventMediator
from spakky.plugins.mediator.post_processor import EventHandlerRegistrationPostProcessor
The historical spakky.event.mediator implementations and spakky.event.post_processor.EventHandlerRegistrationPostProcessor no longer belong to event core. Broker-only services need no mediator installation. No mediator dependency is hidden in the event extra.
Explicit deferral
A local handler may raise spakky.event.EventDeferredError before effects (or after
its transaction rolls back). The mediator propagates this intentional deferral to
the publisher instead of treating it as an ordinary resilient-handler error. It
does not create a local durable retry queue. Kafka implements broker redelivery
through partition pause/rewind, continuous polling and rebalance-aware timers.
Metadata
Release files for spakky-mediator 9.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spakky_mediator-9.1.1.tar.gz | 4.9 kB | With provenance | Details for spakky_mediator-9.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spakky_mediator-9.1.1-py3-none-any.whl | Python 3 | none | any | Details for spakky_mediator-9.1.1-py3-none-any.whl |
Total release size: 11.1 kB
Release files / spakky_mediator-9.1.1.tar.gz
| Download URL | spakky_mediator-9.1.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
10226145f36c1e8f30bbde8205d96ff1da4e0ef74bb56ecc165d34cf6037d87e
|
|
BLAKE2b-256 checksum How to use checksums |
d4af0eaaaf301fe12ab4e2eab057c4e027dfe709bf422b34cf46033c498e6138
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / spakky_mediator-9.1.1-py3-none-any.whl
| Download URL | spakky_mediator-9.1.1-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9f0d7b565bd996154989c7dcf9536026a00c3c3c2964c8b0c81ab969b729580
|
|
BLAKE2b-256 checksum How to use checksums |
7b3a42fd0751bfe8dbd9889475e132656aea1fa823aebaeb7fa18172f6c20479
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logSecurity for spakky-mediator 9.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for spakky_mediator-9.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.