spakky-event¶
spakky-event는 이벤트 계약, 발행, provider 검증, handler stereotype을 제공하는 core 패키지입니다.
제공자 중립 이벤트 시스템 — EventBus, EventTransport 및 consumer/dispatcher 계약
플러그인 진입점¶
initialize(app)
¶
Initialize the spakky-event plugin.
Registers publishing contracts and validates declared handler providers.
Source code in core/spakky-event/src/spakky/event/main.py
Publisher 인터페이스¶
Event publishing and transport interfaces.
Provides publisher, bus, and transport abstractions for event routing: - IEventPublisher: Routes events by type (domain vs integration). - IEventBus: Serializes and sends integration events via transport. - IEventTransport: Low-level transport for serialized event payloads.
IEventPublisher
¶
Bases: ABC
Publishes events by routing to dispatcher or bus based on event type.
publish(event)
abstractmethod
¶
IAsyncEventPublisher
¶
Bases: ABC
Async counterpart of IEventPublisher.
IEventBus
¶
IAsyncEventBus
¶
Bases: ABC
Asynchronous event bus for sending integration events.
send(event)
abstractmethod
async
¶
IEventTransport
¶
Bases: ABC
Low-level synchronous transport for pre-serialized event payloads.
The caller owns the publish batch boundary: hand one or more payloads to send() and call flush() once at the end of the batch. Transports may buffer payloads until flush() so that broker round trips are batched.
send(event_name, payload, headers, partition_key=None)
abstractmethod
¶
Hand a serialized event payload to the broker client for delivery.
A permanent rejection attributable to this record must be reported as
EventDeliveryRejectedError. A connection, timeout, queue, or other
transport-wide failure keeps the client exception's original type so a
caller does not spend this record's retry budget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
Destination topic / routing key. |
required |
payload
|
bytes
|
Pre-serialized event bytes. |
required |
headers
|
dict[str, str]
|
Metadata headers for trace and auth propagation. |
required |
partition_key
|
str | None
|
Key pinning the payload to one broker partition. None spreads payloads round-robin. |
None
|
Raises:
| Type | Description |
|---|---|
EventDeliveryRejectedError
|
When the transport permanently rejects this specific record. |
EventTransportNotRunningError
|
When the transport's broker client is not open, which happens outside the application lifecycle. |
Source code in core/spakky-event/src/spakky/event/event_publisher.py
flush()
abstractmethod
¶
Block until the broker client has finished sending what send() handed over.
A successful return means every record this caller handed over reached the broker. An implementation that learns of a rejection only through a delivery callback collects it and raises here — a caller that batches records has no other moment to learn that the batch did not arrive, and would otherwise record undelivered events as published.
Implementations must preserve the same failure taxonomy as send(): only
a permanent record-specific rejection becomes
EventDeliveryRejectedError; transport-wide failures retain the broker
client's original exception type.
Raises:
| Type | Description |
|---|---|
EventDeliveryRejectedError
|
When one or more records are permanently rejected for a record-specific cause. |
Source code in core/spakky-event/src/spakky/event/event_publisher.py
IAsyncEventTransport
¶
Bases: ABC
Low-level asynchronous transport for pre-serialized event payloads.
The caller owns the publish batch boundary: hand one or more payloads to send() and call flush() once at the end of the batch. Transports may buffer payloads until flush() so that broker round trips are batched. Publishers share one transport, so a batch's send() and flush() belong to the same execution context and flush() reports only that publisher's payloads.
send(event_name, payload, headers, partition_key=None)
abstractmethod
async
¶
Hand a serialized event payload to the broker client for delivery.
A permanent rejection attributable to this record must be reported as
EventDeliveryRejectedError. A connection, timeout, queue, or other
transport-wide failure keeps the client exception's original type so a
caller does not spend this record's retry budget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_name
|
str
|
Destination topic / routing key. |
required |
payload
|
bytes
|
Pre-serialized event bytes. |
required |
headers
|
dict[str, str]
|
Metadata headers for trace and auth propagation. |
required |
partition_key
|
str | None
|
Key pinning the payload to one broker partition. None spreads payloads round-robin. |
None
|
Raises:
| Type | Description |
|---|---|
EventDeliveryRejectedError
|
When the transport permanently rejects this specific record. |
EventTransportNotRunningError
|
When the transport's broker client is not open, which happens outside the application lifecycle. |
Source code in core/spakky-event/src/spakky/event/event_publisher.py
flush()
abstractmethod
async
¶
Block until the broker client has finished sending what send() handed over.
A successful return means every record this caller handed over reached the broker. An implementation that learns of a rejection only through a delivery callback collects it and raises here — a caller that batches records has no other moment to learn that the batch did not arrive, and would otherwise record undelivered events as published.
Implementations must preserve the same failure taxonomy as send(): only
a permanent record-specific rejection becomes
EventDeliveryRejectedError; transport-wide failures retain the broker
client's original exception type.
Raises:
| Type | Description |
|---|---|
EventDeliveryRejectedError
|
When one or more records are permanently rejected for a record-specific cause. |
Source code in core/spakky-event/src/spakky/event/event_publisher.py
Consumer 인터페이스¶
Event consumer interfaces for registering event handlers.
EventHandlerCallback = Callable[[EventT_contra], None]
¶
Synchronous event handler callback type.
AsyncEventHandlerCallback = Callable[[EventT_contra], Awaitable[None]]
¶
Asynchronous event handler callback type.
IEventConsumer
¶
Bases: ABC
Synchronous event consumer interface for registering event handlers.
register(event, handler)
abstractmethod
¶
Register a handler callback for the given event type.
Source code in core/spakky-event/src/spakky/event/event_consumer.py
IAsyncEventConsumer
¶
Bases: ABC
Asynchronous event consumer interface for registering event handlers.
register(event, handler)
abstractmethod
¶
Register an async handler callback for the given event type.
Source code in core/spakky-event/src/spakky/event/event_consumer.py
IDomainEventConsumer
¶
IAsyncDomainEventConsumer
¶
Bases: IAsyncEventConsumer, ABC
Asynchronous provider that registers in-process domain event handlers.
IIntegrationEventConsumer
¶
Bases: IEventConsumer, ABC
Synchronous provider that registers external integration event handlers.
Every implementation follows the delivery contract in
spakky.event.delivery: subscribers read independently, every handler of a
subscriber runs even when another fails, failed handlers are retried under
the subscriber's RetryPolicy, and exhausted messages move to the
subscriber's own dead-letter destination.
register(event, handler, *, subscriber=None, handler_name=None, retry=None)
abstractmethod
¶
Register a handler in the subscription of subscriber for event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
type[EventT_contra]
|
Integration event type the handler receives. |
required |
handler
|
EventHandlerCallback[EventT_contra]
|
Callback invoked with the deserialized event. |
required |
subscriber
|
SubscriberName | None
|
Independent subscriber the handler belongs to. None is the unnamed subscriber that reads through the consumer's base broker identity. |
None
|
handler_name
|
HandlerName | None
|
Name unique within the subscription; it is recorded in dead-letter metadata and in the idempotency key. |
None
|
retry
|
RetryPolicy | None
|
Retry the handler's class declared for its subscriber. Only the fields it sets explicitly override the consumer-wide policy; None follows what the subscriber's other classes declared. |
None
|
Raises:
| Type | Description |
|---|---|
ConflictingSubscriberRetryPolicyError
|
Another handler class of the subscriber declared a different retry. |
Source code in core/spakky-event/src/spakky/event/event_consumer.py
IAsyncIntegrationEventConsumer
¶
Bases: IAsyncEventConsumer, ABC
Asynchronous provider that registers external integration event handlers.
Follows the same delivery contract as IIntegrationEventConsumer.
register(event, handler, *, subscriber=None, handler_name=None, retry=None)
abstractmethod
¶
Register an async handler in the subscription of subscriber for event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
type[EventT_contra]
|
Integration event type the handler receives. |
required |
handler
|
AsyncEventHandlerCallback[EventT_contra]
|
Callback awaited with the deserialized event. |
required |
subscriber
|
SubscriberName | None
|
Independent subscriber the handler belongs to. None is the unnamed subscriber that reads through the consumer's base broker identity. |
None
|
handler_name
|
HandlerName | None
|
Name unique within the subscription; it is recorded in dead-letter metadata and in the idempotency key. |
None
|
retry
|
RetryPolicy | None
|
Retry the handler's class declared for its subscriber. Only the fields it sets explicitly override the consumer-wide policy; None follows what the subscriber's other classes declared. |
None
|
Raises:
| Type | Description |
|---|---|
ConflictingSubscriberRetryPolicyError
|
Another handler class of the subscriber declared a different retry. |
Source code in core/spakky-event/src/spakky/event/event_consumer.py
Dispatcher 인터페이스¶
Event dispatcher interfaces for dispatching events to registered handlers.
This module provides unified dispatcher interfaces that handle all event types. Dispatchers are responsible for delivering events to registered handlers, while Consumers are responsible for handler registration. These interfaces are combined in Mediator implementations.
EventBus¶
Default EventBus implementations that delegate to EventTransport.
DirectEventBus(transport, propagator, auth_snapshot_headers=None)
¶
Bases: IEventBus
Synchronous event bus that serializes and delegates to IEventTransport.
Initialize with the given transport and trace propagator.
Source code in core/spakky-event/src/spakky/event/bus/transport_event_bus.py
send(event)
¶
Serialize and send an integration event via transport.
A direct publish is a batch of one, so the transport is flushed before returning and the caller gets the same delivery guarantee as before.
Source code in core/spakky-event/src/spakky/event/bus/transport_event_bus.py
AsyncDirectEventBus(transport, propagator, auth_snapshot_headers=None)
¶
Bases: IAsyncEventBus
Asynchronous event bus that serializes and delegates to IAsyncEventTransport.
Initialize with the given async transport and trace propagator.
Source code in core/spakky-event/src/spakky/event/bus/transport_event_bus.py
send(event)
async
¶
Serialize and send an integration event via async transport.
A direct publish is a batch of one, so the transport is flushed before returning and the caller gets the same delivery guarantee as before.
Source code in core/spakky-event/src/spakky/event/bus/transport_event_bus.py
Auth Propagation¶
Auth snapshot metadata propagation for outbound integration events.
AuthContextSnapshotHeaderInjector(auth_snapshot_signer=None, auth_snapshot_propagation_configs=())
¶
Bases: IApplicationContextAware
Inject signed AuthContextSnapshot metadata into outbound event headers.
Source code in core/spakky-event/src/spakky/event/auth_propagation.py
set_application_context(application_context)
¶
Inject the application context used to read request-scoped auth state.
Source code in core/spakky-event/src/spakky/event/auth_propagation.py
inject(headers)
¶
Add signed snapshot metadata when outbound propagation is enabled.
Source code in core/spakky-event/src/spakky/event/auth_propagation.py
로컬 제공자¶
로컬 구현은 별도 spakky-mediator 플러그인이 소유합니다.
Publisher¶
Event publisher implementations.
This module provides event publishers that route events by type: - AbstractDomainEvent → EventMediator (in-process dispatch) - AbstractIntegrationEvent → IEventBus (external transport)
EventPublisher(dispatcher, bus)
¶
Bases: IEventPublisher
Routes events by type: domain events to dispatcher, integration events to bus.
Initialize with dispatcher and bus dependencies.
Source code in core/spakky-event/src/spakky/event/publisher/domain_event_publisher.py
publish(event)
¶
Route an event to the appropriate handler based on its type.
Source code in core/spakky-event/src/spakky/event/publisher/domain_event_publisher.py
AsyncEventPublisher(dispatcher, bus)
¶
Bases: IAsyncEventPublisher
Async counterpart that routes events by type.
Initialize with async dispatcher and bus dependencies.
Source code in core/spakky-event/src/spakky/event/publisher/domain_event_publisher.py
publish(event)
async
¶
Route an event to the appropriate async handler based on its type.
Source code in core/spakky-event/src/spakky/event/publisher/domain_event_publisher.py
Aspect¶
Transactional event publishing aspect for automatic domain event publishing.
AsyncTransactionalEventPublishingAspect(collector, publisher)
¶
Bases: IAsyncAspect
Source code in core/spakky-event/src/spakky/event/aspects/transactional_event_publishing.py
after_returning_async(result)
async
¶
Publish domain events of the transactions this call committed.
A call that joined an outer transaction committed nothing, so it publishes nothing; its events go out once the outermost call commits.
Source code in core/spakky-event/src/spakky/event/aspects/transactional_event_publishing.py
TransactionalEventPublishingAspect(collector, publisher)
¶
Bases: IAspect
Source code in core/spakky-event/src/spakky/event/aspects/transactional_event_publishing.py
after_returning(result)
¶
Publish domain events of the transactions this call committed.
A call that joined an outer transaction committed nothing, so it publishes nothing; its events go out once the outermost call commits.
Source code in core/spakky-event/src/spakky/event/aspects/transactional_event_publishing.py
전달 계약¶
통합 이벤트 소비자가 공통으로 따르는 구독자·재시도·dead-letter 계약입니다. 사용법은 이벤트 시스템 가이드를 참고하세요.
Subscriber identity shared by every integration event consumer.
A subscriber is one independent reader of an event stream. Each subscriber owns its consume position, retry state and dead-letter destination, so one subscriber failing or falling behind never affects another.
DEFAULT_SUBSCRIBER_KEY = ''
module-attribute
¶
Idempotency-key value recorded for handlers that declare no subscriber.
SUBSCRIBER_NAME_PATTERN = compile_pattern('^[A-Za-z0-9][A-Za-z0-9_-]{0,62}$')
module-attribute
¶
Names must stay valid inside Kafka group/topic names and RabbitMQ queue names.
A dot is excluded on purpose: brokers derive <event>.<subscriber>.<suffix>
resource names, and a dot inside the name would make them ambiguous.
RESERVED_SUBSCRIBER_NAMES = frozenset({'dlq', 'dlt', 'retry', 'redrive'})
module-attribute
¶
Names brokers append to derive dead-letter, retry and redrive resources.
A subscriber with one of these names would share a resource with the unnamed
subscriber, e.g. its queue <event>.dlq is that subscriber's dead-letter queue.
SubscriberName = str
¶
Name of one independent subscriber; broker resources are derived from it.
HandlerName = str
¶
Stable name of one handler inside a subscriber; part of the idempotency key.
InvalidSubscriberNameError(subscriber)
¶
Bases: AbstractSpakkyEventError
Raised when a subscriber name cannot be mapped onto broker resources.
Source code in core/spakky-event/src/spakky/event/subscription.py
DuplicateEventHandlerNameError(subscriber, handler_name)
¶
Bases: AbstractSpakkyEventError
Raised when two handlers of one subscription share a handler name.
Source code in core/spakky-event/src/spakky/event/subscription.py
MixedSubscriptionModeError(subscriber, event_type)
¶
Bases: AbstractSpakkyEventError
Raised when one subscription mixes sync and async handlers.
Sync and async handlers are served by two separate consumers. Both would read the same broker subscription and split its messages between them, so each handler would silently miss part of the stream.
Source code in core/spakky-event/src/spakky/event/subscription.py
ConflictingSubscriberRetryPolicyError(subscriber)
¶
Bases: AbstractSpakkyEventError
Raised when handler classes of one subscriber declare different retries.
One worker serves every event of a subscriber, so the subscriber has one retry policy. Classes that declare none follow the declared one; two classes that declare different ones leave no single policy to apply.
Source code in core/spakky-event/src/spakky/event/subscription.py
SubscriberNames
¶
Validation and key mapping for subscriber names.
validate(subscriber)
staticmethod
¶
Reject names that cannot be turned into broker resource names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subscriber
|
SubscriberName | None
|
Declared name, or None for the unnamed subscriber. |
required |
Returns:
| Type | Description |
|---|---|
SubscriberName | None
|
The same value once it is known to be usable. |
Raises:
| Type | Description |
|---|---|
InvalidSubscriberNameError
|
The name has unsupported characters or is reserved for derived broker resources. |
Source code in core/spakky-event/src/spakky/event/subscription.py
key(subscriber)
staticmethod
¶
Return the value stored for a subscriber in records and headers.
Broker-neutral delivery contract every integration event consumer implements.
The contract fixes what running the handlers of one subscriber means, so Kafka, RabbitMQ and the in-memory broker behave the same way:
- every handler of the subscriber runs even when an earlier one fails;
- a delivery is retried while a failed handler remains, and a retry runs only the handlers that have not succeeded yet; a pending handler that is no longer registered counts as a non-retryable failure, never as done;
- retries are limited by
RetryPolicy; a message that exhausts them, or that has a failure retrying cannot fix, moves to the subscriber's dead-letter destination together withDeadLettermetadata; - a handler asking to wait (
EventDeferredError) makes the delivery wait without counting an attempt, unless another handler failed for good; - a dead letter is redriven to the subscriber it failed for, and to no other;
- an unavailable auth provider is no verdict about the message: the error
leaves
deliver, and the adapter must keep the message unacknowledged.
A broker adapter maps the returned DeliveryOutcome onto its own mechanics
(offset commit, ack, pause, retry destination, dead-letter destination).
RetryPolicyResolver = Callable[[SubscriberName | None, RetryPolicy | None], RetryPolicy]
¶
Turns a subscriber and the retry its handlers declared into the policy it uses.
The declared retry is None when no handler class of the subscriber declared one.
DeliveryHeaders = Mapping[str, str]
¶
String-valued message headers as every broker adapter exposes them.
DeliveryOutcome = DeliveryCompleted | DeliveryRetry | DeliveryDeferred | DeliveryDeadLettered
¶
What one delivery attempt settled; adapters map it onto broker mechanics.
DeliveryHeader
¶
Bases: StrEnum
Headers that carry retry state with a message set aside for a retry.
DeadLetterHeader
¶
Bases: StrEnum
Headers every dead-lettered message carries, on every broker.
DeliveryState
¶
Bases: BaseModel
Where one message stands in its retry sequence for one subscriber.
attempt = Field(default=1, ge=1)
class-attribute
instance-attribute
¶
1-based number of the attempt about to run.
pending = None
class-attribute
instance-attribute
¶
Handlers still to run; None means every handler (first delivery).
to_headers()
¶
Encode the state so it can travel with a message set aside for retry.
Source code in core/spakky-event/src/spakky/event/delivery.py
from_headers(headers)
classmethod
¶
Decode the state of a message; absent headers mean a first delivery.
Raises:
| Type | Description |
|---|---|
InvalidDeliveryHeaderError
|
A present header cannot be decoded. |
Source code in core/spakky-event/src/spakky/event/delivery.py
HandlerFailure
¶
Bases: BaseModel
Why one handler did not complete in the last attempt.
DeadLetter
¶
Bases: BaseModel
Metadata stored with a message a subscriber gave up on.
event_name
instance-attribute
¶
Destination (topic, routing key) the message was originally published to.
subscriber
instance-attribute
¶
Subscriber the message failed for; None is the unnamed subscriber.
failures
instance-attribute
¶
Handlers that had not succeeded when the subscriber gave up.
attempts
instance-attribute
¶
Number of delivery attempts made before giving up.
failed_at
instance-attribute
¶
When the last attempt ended.
pending
property
¶
Handlers a redrive has to run.
to_headers()
¶
Encode the metadata as dead-letter message headers.
Source code in core/spakky-event/src/spakky/event/delivery.py
from_headers(headers)
classmethod
¶
Decode dead-letter metadata from message headers.
Raises:
| Type | Description |
|---|---|
InvalidDeliveryHeaderError
|
A header is absent or cannot be decoded. |
Source code in core/spakky-event/src/spakky/event/delivery.py
DeliveryCompleted
¶
Bases: BaseModel
Every handler is done; the adapter acknowledges the message.
DeliveryRetry
¶
Bases: BaseModel
A handler failed and attempts remain; deliver again after delay.
DeliveryDeferred
¶
Bases: BaseModel
A handler asked to wait; deliver again without counting an attempt.
DeliveryDeadLettered
¶
Bases: BaseModel
The subscriber gave up; the adapter stores the message as a dead letter.
EventDeliveryContext
¶
Bases: BaseModel
Identity of the handler call a consumer is making right now.
Set around every handler invocation so that cross-cutting code, such as the idempotency aspect, can key its records without the handler passing it on.
subscriber
instance-attribute
¶
Subscriber key; the unnamed subscriber is the empty string.
activate()
¶
deactivate(token)
classmethod
¶
Restore whatever delivery was in progress before activate.
current()
classmethod
¶
Return the delivery in progress.
Raises:
| Type | Description |
|---|---|
EventDeliveryContextUnavailableError
|
No consumer is delivering. |
Source code in core/spakky-event/src/spakky/event/delivery.py
current_or_none()
classmethod
¶
Return the delivery in progress, or None outside a consumer call.
RegisteredEventHandler(name, callback)
dataclass
¶
One named handler of a subscription.
DeliveryAttempt(event_name, subscriber, policy, state, failures, deferred, retry_after)
dataclass
¶
Mutable tally of one delivery attempt, settled into a DeliveryOutcome.
record_failure(handler, error)
¶
Keep a handler failure for the retry decision and dead-letter metadata.
Source code in core/spakky-event/src/spakky/event/delivery.py
record_deferral(handler, error)
¶
Keep a handler's request to be delivered again later.
Source code in core/spakky-event/src/spakky/event/delivery.py
settle()
¶
Turn the tally into the outcome the broker adapter has to act on.
One message gets one outcome, so mixed handler results follow a fixed precedence: a non-retryable failure dead-letters the delivery at once, otherwise a deferral makes the whole delivery wait without counting an attempt, otherwise the failures are retried while attempts remain. In every case the handlers that have not succeeded stay pending together.
Source code in core/spakky-event/src/spakky/event/delivery.py
SubscriptionDelivery(event_type, subscriber, policy)
¶
Runs the sync handlers one subscriber registered for one event type.
Source code in core/spakky-event/src/spakky/event/delivery.py
add(name, callback)
¶
Add a handler under a name unique within this subscription.
Raises:
| Type | Description |
|---|---|
DuplicateEventHandlerNameError
|
The name is already taken. |
Source code in core/spakky-event/src/spakky/event/delivery.py
deliver(event, state=None, invoker=None)
¶
Run every pending handler once and settle the attempt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
AbstractEvent
|
Deserialized event to hand to the handlers. |
required |
state
|
DeliveryState | None
|
Retry state of the message; None means a first delivery. |
None
|
invoker
|
Callable[[RegisteredEventHandler[EventHandlerCallback[Any]], AbstractEvent], None] | None
|
Adapter hook that calls a handler with adapter-specific
arguments; None calls |
None
|
Returns:
| Type | Description |
|---|---|
DeliveryOutcome
|
What the adapter must do with the message. |
Raises:
| Type | Description |
|---|---|
AuthVerificationProviderUnavailableError
|
Snapshot verification is unavailable; the message must stay unacknowledged. |
AuthRequirementProviderUnavailableError
|
Authorization data is unavailable; the message must stay unacknowledged. |
Source code in core/spakky-event/src/spakky/event/delivery.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | |
AsyncSubscriptionDelivery(event_type, subscriber, policy)
¶
Runs the async handlers one subscriber registered for one event type.
Source code in core/spakky-event/src/spakky/event/delivery.py
add(name, callback)
¶
Add a handler under a name unique within this subscription.
Raises:
| Type | Description |
|---|---|
DuplicateEventHandlerNameError
|
The name is already taken. |
Source code in core/spakky-event/src/spakky/event/delivery.py
deliver(event, state=None, invoker=None)
async
¶
Run every pending handler once and settle the attempt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
AbstractEvent
|
Deserialized event to hand to the handlers. |
required |
state
|
DeliveryState | None
|
Retry state of the message; None means a first delivery. |
None
|
invoker
|
Callable[[RegisteredEventHandler[AsyncEventHandlerCallback[Any]], AbstractEvent], Awaitable[None]] | None
|
Adapter hook that calls a handler with adapter-specific
arguments; None awaits |
None
|
Returns:
| Type | Description |
|---|---|
DeliveryOutcome
|
What the adapter must do with the message. |
Raises:
| Type | Description |
|---|---|
AuthVerificationProviderUnavailableError
|
Snapshot verification is unavailable; the message must stay unacknowledged. |
AuthRequirementProviderUnavailableError
|
Authorization data is unavailable; the message must stay unacknowledged. |
Source code in core/spakky-event/src/spakky/event/delivery.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | |
EventSubscriptions(policy, resolver=None)
¶
Sync subscriptions of one consumer, keyed by subscriber and event type.
Every subscription of one subscriber shares that subscriber's retry policy, because one worker serves all of its events.
Create an empty registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
RetryPolicy
|
Consumer-wide retry every subscriber starts from. |
required |
resolver
|
RetryPolicyResolver | None
|
Turns a subscriber and its declared retry into the policy
it uses. None overlays the declared retry on |
None
|
Source code in core/spakky-event/src/spakky/event/delivery.py
policy = policy
instance-attribute
¶
Consumer-wide retry every subscriber starts from.
policy_of(subscriber)
¶
Return the retry policy subscriber uses for every event it reads.
register(event, handler, subscriber=None, handler_name=None, retry=None)
¶
Add a handler to the subscription of subscriber for event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
type[AbstractEvent]
|
Event type the handler receives. |
required |
handler
|
EventHandlerCallback[Any]
|
Callback invoked with the deserialized event. |
required |
subscriber
|
SubscriberName | None
|
Subscriber the handler belongs to; None is unnamed. |
None
|
handler_name
|
HandlerName | None
|
Stable name inside the subscription. None derives a positional name, which is not stable enough for idempotency. |
None
|
retry
|
RetryPolicy | None
|
Retry the handler's class declared for its subscriber; None follows whatever the subscriber's other classes declared. |
None
|
Returns:
| Type | Description |
|---|---|
SubscriptionDelivery
|
The subscription the handler was added to. |
Raises:
| Type | Description |
|---|---|
InvalidSubscriberNameError
|
The subscriber name is unusable. |
ConflictingSubscriberRetryPolicyError
|
Another handler class of the subscriber declared a different retry. |
Source code in core/spakky-event/src/spakky/event/delivery.py
get(subscriber, event)
¶
Return the subscription of subscriber for event.
Raises:
| Type | Description |
|---|---|
SubscriptionNotFoundError
|
Nothing is registered for the pair. |
Source code in core/spakky-event/src/spakky/event/delivery.py
AsyncEventSubscriptions(policy, resolver=None)
¶
Async subscriptions of one consumer, keyed by subscriber and event type.
Every subscription of one subscriber shares that subscriber's retry policy, because one worker serves all of its events.
Create an empty registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
RetryPolicy
|
Consumer-wide retry every subscriber starts from. |
required |
resolver
|
RetryPolicyResolver | None
|
Turns a subscriber and its declared retry into the policy
it uses. None overlays the declared retry on |
None
|
Source code in core/spakky-event/src/spakky/event/delivery.py
policy = policy
instance-attribute
¶
Consumer-wide retry every subscriber starts from.
policy_of(subscriber)
¶
Return the retry policy subscriber uses for every event it reads.
register(event, handler, subscriber=None, handler_name=None, retry=None)
¶
Add a handler to the subscription of subscriber for event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
type[AbstractEvent]
|
Event type the handler receives. |
required |
handler
|
AsyncEventHandlerCallback[Any]
|
Callback awaited with the deserialized event. |
required |
subscriber
|
SubscriberName | None
|
Subscriber the handler belongs to; None is unnamed. |
None
|
handler_name
|
HandlerName | None
|
Stable name inside the subscription. None derives a positional name, which is not stable enough for idempotency. |
None
|
retry
|
RetryPolicy | None
|
Retry the handler's class declared for its subscriber; None follows whatever the subscriber's other classes declared. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncSubscriptionDelivery
|
The subscription the handler was added to. |
Raises:
| Type | Description |
|---|---|
InvalidSubscriberNameError
|
The subscriber name is unusable. |
ConflictingSubscriberRetryPolicyError
|
Another handler class of the subscriber declared a different retry. |
Source code in core/spakky-event/src/spakky/event/delivery.py
get(subscriber, event)
¶
Return the subscription of subscriber for event.
Raises:
| Type | Description |
|---|---|
SubscriptionNotFoundError
|
Nothing is registered for the pair. |
Source code in core/spakky-event/src/spakky/event/delivery.py
EventRouting
¶
Routing identity of event types shared by publishers and consumers.
name_of(event)
staticmethod
¶
Return the destination name an event type is published under.
event_name is an instance property that subclasses may override with
a class-static value, so it is read through an uninitialized instance.
Source code in core/spakky-event/src/spakky/event/delivery.py
Redrive contract: hand dead letters back to the subscriber they failed for.
RedriveResult
¶
IEventRedriver
¶
Bases: ABC
Synchronous redrive of one subscriber's dead letters.
A redrive reaches only the subscriber that dead-lettered the message, and runs only the handlers recorded as failed. Other subscribers of the same event never see the message again.
redrive(event, *, subscriber=None, limit=None)
abstractmethod
¶
Deliver dead letters of subscriber for event to their failed handlers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
type[AbstractIntegrationEvent]
|
Event type whose dead letters are redriven. |
required |
subscriber
|
SubscriberName | None
|
Subscriber owning the dead letters; None is unnamed. |
None
|
limit
|
int | None
|
Most dead letters to take in this call; None takes all currently stored. |
None
|
Returns:
| Type | Description |
|---|---|
RedriveResult
|
Counts of dead letters that completed and that failed again. |
Source code in core/spakky-event/src/spakky/event/redrive.py
IAsyncEventRedriver
¶
Bases: ABC
Asynchronous redrive of one subscriber's dead letters.
Follows the same contract as IEventRedriver.
redrive(event, *, subscriber=None, limit=None)
abstractmethod
async
¶
Deliver dead letters of subscriber for event to their failed handlers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
type[AbstractIntegrationEvent]
|
Event type whose dead letters are redriven. |
required |
subscriber
|
SubscriberName | None
|
Subscriber owning the dead letters; None is unnamed. |
None
|
limit
|
int | None
|
Most dead letters to take in this call; None takes all currently stored. |
None
|
Returns:
| Type | Description |
|---|---|
RedriveResult
|
Counts of dead letters that completed and that failed again. |
Source code in core/spakky-event/src/spakky/event/redrive.py
멱등 소비¶
Idempotent consumption contract for integration event handlers.
Brokers deliver at least once, so a handler can see the same event again after
a crash, a rebalance or a retry. @Idempotent() makes a handler skip an event
it has already processed. The record is keyed by subscriber, handler and event
id, and is written through the handler's own transaction, so the record and the
handler's changes commit or roll back together.
ProcessedEventKey
¶
Bases: BaseModel
Identity of one handler having processed one event.
subscriber
instance-attribute
¶
Subscriber key; the unnamed subscriber is the empty string.
ProcessedEventStoreUnavailableError
¶
Bases: AbstractSpakkyEventError
Raised when an idempotent handler runs without a processed-event store.
IProcessedEventStore
¶
Bases: ABC
Synchronous store of processed-event records.
record must write through the transaction that is active for the calling
handler and must fail when none is active; a record committed apart from
the handler's changes would either lose the event or process it twice.
exists(key)
abstractmethod
¶
record(key)
abstractmethod
¶
Record the event as processed inside the caller's transaction.
A concurrent duplicate must fail here or at commit, never be accepted twice.
Source code in core/spakky-event/src/spakky/event/idempotency.py
purge(older_than)
abstractmethod
¶
Delete records processed before older_than.
Returns:
| Type | Description |
|---|---|
int
|
Number of records removed. |
IAsyncProcessedEventStore
¶
Bases: ABC
Asynchronous store of processed-event records.
Follows the same contract as IProcessedEventStore.
exists(key)
abstractmethod
async
¶
record(key)
abstractmethod
async
¶
Record the event as processed inside the caller's transaction.
A concurrent duplicate must fail here or at commit, never be accepted twice.
Source code in core/spakky-event/src/spakky/event/idempotency.py
purge(older_than)
abstractmethod
async
¶
Delete records processed before older_than.
Returns:
| Type | Description |
|---|---|
int
|
Number of records removed. |
Idempotent()
dataclass
¶
Bases: FunctionAnnotation
Marks an integration event handler as processing each event once.
Combine it with @Transactional() so the processed record and the
handler's changes share one transaction:
@EventHandler(subscriber="billing")
class BillingHandler:
@on_event(OrderPlaced)
@Transactional()
@Idempotent()
async def charge(self, event: OrderPlaced) -> None: ...
idempotent(func)
¶
Decorator form of Idempotent().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[P, R]
|
Event handler method to mark. |
required |
Returns:
| Type | Description |
|---|---|
Callable[P, R]
|
The same method carrying the idempotency annotation. |
Source code in core/spakky-event/src/spakky/event/idempotency.py
Aspects that skip integration events a handler has already processed.
IDEMPOTENT_ASPECT_ORDER = 2
module-attribute
¶
Runs inside TransactionalAspect (order 1) so the record joins its transaction.
AsyncIdempotentAspect
¶
Bases: IAsyncAspect, IContainerAware
Skips an async handler call for an event that handler already processed.
set_container(container)
¶
Keep the container so the store is resolved only when a handler needs it.
IdempotentAspect
¶
Bases: IAspect, IContainerAware
Skips a sync handler call for an event that handler already processed.
set_container(container)
¶
Keep the container so the store is resolved only when a handler needs it.
메모리 구현체¶
자동으로 등록되지 않습니다. spakky.event.memory.main.initialize(app)로 켭니다.
Opt-in registration of the in-memory integration event broker.
initialize(app)
¶
Register the in-memory broker as the integration event provider.
This is not a plugin entry point and is never loaded automatically: call it explicitly, and do not combine it with a broker plugin in one application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
SpakkyApplication
|
Application that should run integration events in memory. |
required |
Source code in core/spakky-event/src/spakky/event/memory/main.py
In-memory broker that fans published events out to subscriber queues.
IN_FLIGHT_POLL_INTERVAL = 0.001
module-attribute
¶
Seconds drain waits between checks on a message another consumer is handling.
SubscriptionKey = tuple[str, SubscriberName | None]
¶
Event name and subscriber identifying one in-memory queue.
InMemoryMessage
¶
Bases: BaseModel
One published event as a subscriber queue holds it.
partition_key = None
class-attribute
instance-attribute
¶
Recorded for assertions; in-memory queues are not partitioned.
state = DeliveryState()
class-attribute
instance-attribute
¶
Retry state of this message for the subscriber owning the queue.
not_before = 0.0
class-attribute
instance-attribute
¶
Monotonic time before which the message must not be delivered.
InMemoryDeadLetter
¶
Bases: BaseModel
A message a subscriber gave up on, with the reason.
InMemoryEventBroker()
¶
Holds one queue and one dead-letter list per subscriber and event.
Publishing copies the message into the queue of every subscriber bound to
the event name, so subscribers consume independently. A message published
while no subscriber is bound is kept only in published.
Source code in core/spakky-event/src/spakky/event/memory/broker.py
published = []
instance-attribute
¶
Every message ever published, in order, for test assertions.
idle
property
¶
Whether no message is queued or being handled.
bind(key)
¶
Create the queue of a subscriber; later publishes are copied into it.
attach(drain)
¶
attach_async(drain)
¶
Let drain_async reach an async consumer bound to this broker.
publish(message)
¶
Copy a message into the queue of every subscriber of its event name.
Source code in core/spakky-event/src/spakky/event/memory/broker.py
take(key, now, head_only)
¶
Remove and return the next deliverable message of one queue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
SubscriptionKey
|
Queue to read. |
required |
now
|
float
|
Current monotonic time. |
required |
head_only
|
bool
|
Only the oldest message may be taken, so a waiting retry
blocks the messages behind it and order is preserved. The queue
then also stays closed to other consumers until |
required |
Returns:
| Type | Description |
|---|---|
InMemoryMessage | None
|
A due message, counted as in flight until |
Source code in core/spakky-event/src/spakky/event/memory/broker.py
done(key)
¶
Mark a taken message as settled, after any requeue or dead-letter.
requeue_front(key, message)
¶
Put a message back as the oldest one of its queue.
requeue_back(key, message)
¶
Put a message back behind everything already queued.
next_due_in(keys, now, head_only)
¶
Return seconds until a queued message becomes deliverable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
list[SubscriptionKey]
|
Queues to inspect. |
required |
now
|
float
|
Current monotonic time. |
required |
head_only
|
bool
|
Only the oldest message of each queue can become
deliverable, matching |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
None when the given queues are empty. |
Source code in core/spakky-event/src/spakky/event/memory/broker.py
add_dead_letter(key, entry)
¶
Store a message a subscriber gave up on.
take_dead_letters(key, limit)
¶
Remove and return up to limit oldest dead letters of one subscriber.
Source code in core/spakky-event/src/spakky/event/memory/broker.py
dead_letters(event_name, subscriber=None)
¶
Return the dead letters one subscriber holds for an event name.
Source code in core/spakky-event/src/spakky/event/memory/broker.py
queued(event_name, subscriber=None)
¶
Return the messages still waiting in one subscriber queue.
Source code in core/spakky-event/src/spakky/event/memory/broker.py
drain()
¶
Deliver through the sync consumers until they make no progress.
Messages queued for async subscribers are left for drain_async. A
message a background consumer is still handling is waited for, so the
effects of every delivery are visible when this returns.
Returns:
| Type | Description |
|---|---|
int
|
Number of deliveries made by this call. |
Source code in core/spakky-event/src/spakky/event/memory/broker.py
drain_async()
async
¶
Deliver through every consumer until the broker makes no progress.
Handlers may publish further events; those are delivered as well. A message a background consumer is still handling is waited for, so the effects of every delivery are visible when this returns.
Returns:
| Type | Description |
|---|---|
int
|
Number of deliveries made by this call. |
Source code in core/spakky-event/src/spakky/event/memory/broker.py
Consumers that deliver in-memory broker messages to registered handlers.
InMemorySettlement
¶
Applies a delivery outcome to the in-memory broker.
undeserializable(message, subscriber, handlers, error)
staticmethod
¶
Dead-letter a payload no retry can turn into the event type.
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
still_dead(entry, outcome)
staticmethod
¶
Keep a redriven dead letter, narrowed to the handlers that failed again.
Handlers that succeeded in this redrive leave the metadata, so the next redrive does not run them a second time.
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
next_due_in(broker, queues, now)
staticmethod
¶
Return seconds until a message of any queue becomes deliverable.
Each subscriber has its own retry mode, so a blocking queue only offers its oldest message while a delayed queue offers every message.
Returns:
| Type | Description |
|---|---|
float | None
|
None when every given queue is empty. |
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
apply(broker, key, message, outcome, mode)
staticmethod
¶
Requeue, dead-letter or drop the message as the outcome requires.
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
InMemoryEventConsumer(broker, config)
¶
Bases: IIntegrationEventConsumer, IEventRedriver, AbstractBackgroundService
Delivers in-memory messages to sync handlers under the delivery contract.
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
register(event, handler, *, subscriber=None, handler_name=None, retry=None)
¶
Register a handler and bind its subscriber queue to the event.
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
drain()
¶
Deliver every queued message, waiting out retry delays.
Returns:
| Type | Description |
|---|---|
int
|
Number of deliveries made, retries included. |
initialize()
¶
run()
¶
Deliver messages as they arrive until the service is stopped.
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
dispose()
¶
redrive(event, *, subscriber=None, limit=None)
¶
Run the failed handlers of this subscriber's dead letters again.
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
AsyncInMemoryEventConsumer(broker, config)
¶
Bases: IAsyncIntegrationEventConsumer, IAsyncEventRedriver, AbstractAsyncBackgroundService
Delivers in-memory messages to async handlers under the delivery contract.
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
register(event, handler, *, subscriber=None, handler_name=None, retry=None)
¶
Register an async handler and bind its subscriber queue to the event.
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
drain_async()
async
¶
Deliver every queued message, waiting out retry delays.
Returns:
| Type | Description |
|---|---|
int
|
Number of deliveries made, retries included. |
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
initialize_async()
async
¶
run_async()
async
¶
Deliver messages as they arrive until the service is stopped.
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
dispose_async()
async
¶
redrive(event, *, subscriber=None, limit=None)
async
¶
Run the failed handlers of this subscriber's dead letters again.
Source code in core/spakky-event/src/spakky/event/memory/consumer.py
Transports that publish serialized integration events into the in-memory broker.
InMemoryEventTransport(broker)
¶
Bases: IEventTransport
Synchronous transport backed by InMemoryEventBroker.
Source code in core/spakky-event/src/spakky/event/memory/transport.py
send(event_name, payload, headers, partition_key=None)
¶
Publish the payload to every subscriber queue of event_name.
Source code in core/spakky-event/src/spakky/event/memory/transport.py
AsyncInMemoryEventTransport(broker)
¶
Bases: IAsyncEventTransport
Asynchronous transport backed by InMemoryEventBroker.
Source code in core/spakky-event/src/spakky/event/memory/transport.py
send(event_name, payload, headers, partition_key=None)
async
¶
Publish the payload to every subscriber queue of event_name.
Source code in core/spakky-event/src/spakky/event/memory/transport.py
Configuration of the in-memory integration event broker.
InMemoryEventConfig()
¶
Bases: BaseSettings
Retry and polling settings of the in-memory broker.
Source code in core/spakky-event/src/spakky/event/memory/config.py
스테레오타입¶
EventHandler stereotype and event routing decorators.
This module provides @EventHandler stereotype and @on_event decorator for organizing event-driven architectures.
EventHandlerMethod = Callable[[Any, EventT_contra], None | Awaitable[None]]
¶
Type alias for event handler callback functions.
EventRoute(event_type, name=None)
dataclass
¶
Bases: FunctionAnnotation
Annotation for marking methods as event handlers.
Associates a method with a specific domain event type.
event_type
instance-attribute
¶
The domain event type this handler processes.
name = None
class-attribute
instance-attribute
¶
Explicit handler name; None derives <Class>.<method>.
The name identifies the handler in dead-letter metadata and in the idempotency key, so set it explicitly when the method may be renamed.
handler_name(owner, method_name)
¶
Return the name this handler is registered under.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
type
|
Event handler class declaring the method. |
required |
method_name
|
str
|
Name of the decorated method. |
required |
Source code in core/spakky-event/src/spakky/event/stereotype/event_handler.py
__call__(obj)
¶
Apply event route annotation to method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
EventHandlerMethod[EventT_contra]
|
The method to annotate. |
required |
Returns:
| Type | Description |
|---|---|
EventHandlerMethod[EventT_contra]
|
The annotated method. |
Source code in core/spakky-event/src/spakky/event/stereotype/event_handler.py
DeclaredEventRoute(method_name, route, asynchronous, handler_name)
dataclass
¶
One @on_event method as declared on an event handler class.
method_name
instance-attribute
¶
Attribute name to look the bound method up on a handler instance.
EventHandler(*, name='', scope=Scope.SINGLETON, subscriber=None, retry=None)
dataclass
¶
Bases: Pod
Stereotype for event handler classes.
EventHandlers contain methods decorated with @on_event that process domain events asynchronously.
Example
@EventHandler(subscriber="billing", retry=RetryPolicy(max_attempts=3)) class BillingHandler: @on_event(OrderPlaced) async def charge(self, event: OrderPlaced) -> None: ...
subscriber = field(kw_only=True, default=None)
class-attribute
instance-attribute
¶
Independent subscriber the integration handlers of this class belong to.
Each subscriber reads an integration event stream on its own: it has its own consume position, retries and dead-letter destination. None keeps the handlers on the unnamed subscriber of the consumer. Domain events are dispatched in process and ignore this value.
retry = field(kw_only=True, default=None)
class-attribute
instance-attribute
¶
Retry the subscriber of this class uses; None declares nothing.
Only the fields set explicitly override the consumer-wide policy, so
RetryPolicy(mode=RetryMode.DELAYED) keeps the attempt counts and intervals
of the deployment settings. The value covers every event of the subscriber:
classes of the same subscriber that declare none follow it, and two classes
that declare different values fail registration with
ConflictingSubscriberRetryPolicyError.
__post_init__()
¶
Reject subscriber names that cannot become broker resource names.
routes()
¶
List the @on_event methods declared on the handler class.
Routes are read from the class, not from an instance: an instance may be an AOP proxy whose attributes are plain callables, and scanning it for bound methods would silently miss every advised handler.
Source code in core/spakky-event/src/spakky/event/stereotype/event_handler.py
on_event(event_type, *, name=None)
¶
Decorator for marking methods as event handlers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
type[EventT_contra]
|
The domain event type to handle. |
required |
name
|
HandlerName | None
|
Explicit handler name; None derives |
None
|
Returns:
| Type | Description |
|---|---|
Callable[[EventHandlerMethod[EventT_contra]], EventHandlerMethod[EventT_contra]]
|
Decorator function that applies EventRoute annotation. |
Example
@EventHandler() class UserEventHandler: @on_event(UserCreatedEvent) async def handle_user_created(self, event: UserCreatedEvent) -> None: # Handle event pass
Source code in core/spakky-event/src/spakky/event/stereotype/event_handler.py
후처리기¶
Fail startup when declared handlers lack an explicit consumer provider.
EventHandlerProviderValidationPostProcessor()
¶
Bases: IPostProcessor, IContainerAware
Validate domain/integration and sync/async capabilities without a hidden provider.
Source code in core/spakky-event/src/spakky/event/post_processor.py
set_container(container)
¶
Receive the provider-neutral registry for startup validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
IContainer
|
Registry containing only explicitly selected providers. |
required |
Source code in core/spakky-event/src/spakky/event/post_processor.py
post_process(pod)
¶
Fail deterministically when a declared handler would remain unregistered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pod
|
object
|
Constructed business or infrastructure Pod. |
required |
Returns:
| Type | Description |
|---|---|
object
|
The original Pod after validating all declared event routes. |
Raises:
| Type | Description |
|---|---|
EventHandlerProviderUnavailableError
|
No provider supports the handler role. |
MixedSubscriptionModeError
|
One subscription mixes sync and async handlers. |
Source code in core/spakky-event/src/spakky/event/post_processor.py
에러¶
AbstractSpakkyEventError
¶
InvalidMessageError
¶
IntegrationEventTransportUnavailableError
¶
Bases: AbstractSpakkyEventError
Raised when integration events are published without a broker transport.
AuthSnapshotPropagationSignerUnavailableError
¶
AuthSnapshotPropagationContextUnavailableError
¶
Bases: AbstractSpakkyEventError
Raised when signed snapshot propagation cannot read ApplicationContext.
EventTransportNotRunningError
¶
Bases: AbstractSpakkyEventError
Raised when a transport is used outside the application lifecycle.
Transports whose broker client is opened at application start and closed at application stop raise this instead of publishing into a closed client, so that callers can tell a shutdown window apart from a delivery failure.
EventDeliveryRejectedError(reasons)
¶
Bases: AbstractSpakkyEventError
Raised when a transport attributes a permanent rejection to a record.
A client may report the rejection synchronously from send() or later through a delivery callback consumed by flush(). Both paths use this error so callers can distinguish record-specific failure from a transport-wide outage.
Source code in core/spakky-event/src/spakky/event/error.py
UnknownEventTypeError(event_type)
¶
Bases: AbstractSpakkyEventError
Raised when an event type is neither domain nor integration.
Source code in core/spakky-event/src/spakky/event/error.py
DomainEventDispatcherUnavailableError
¶
Bases: AbstractSpakkyEventError
Raised when local domain publishing has no configured dispatcher provider.
EventHandlerProviderUnavailableError(handler, event_type, provider_type)
¶
Bases: AbstractSpakkyEventError
Raised at startup when a declared event handler has no matching consumer.
Keep the missing provider and affected handler in startup diagnostics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handler
|
str
|
Fully qualified method declaring the unsupported handler. |
required |
event_type
|
type
|
Declared domain or integration event type. |
required |
provider_type
|
type
|
Required synchronous or asynchronous consumer role. |
required |
Source code in core/spakky-event/src/spakky/event/error.py
InvalidEventDeferralError
¶
EventDeferredError(retry_after=1.0)
¶
Bases: AbstractSpakkyEventError
Defer delivery without counting a handler failure or acknowledging it.
Raise before effects, or let a transaction roll back before this reaches the consumer. Earlier handlers may run again and must remain idempotent. Broker consumers supporting deferral retry after the delay while continuing to poll. Direct in-process dispatch propagates the error to its caller.
Source code in core/spakky-event/src/spakky/event/error.py
AbstractNonRetryableEventError
¶
Bases: AbstractSpakkyEventError, ABC
Base for handler failures that another delivery attempt cannot fix.
A consumer skips the remaining retry attempts for such a failure and moves the message to the subscriber's dead-letter destination.
InvalidDeliveryHeaderError
¶
EventDeliveryContextUnavailableError
¶
Bases: AbstractSpakkyEventError
Raised when delivery metadata is read outside a consumer-driven handler call.
SubscriptionNotFoundError(subscriber, event_type)
¶
Bases: AbstractSpakkyEventError
Raised when no handler is registered for a subscriber and event type.
Source code in core/spakky-event/src/spakky/event/error.py
EventHandlerNotRegisteredError
¶
Bases: AbstractNonRetryableEventError
Recorded when a delivery names a handler its subscription no longer has.
A retry or redrive carries the names of the handlers still to run. If one was renamed or removed, completing the delivery would discard the message without running anything, so it is kept as a failure instead.