Skip to content

feat: Add reusable event dispatch and delivery - #1

Merged
nfebe merged 3 commits into
mainfrom
feat/event-primitives
Nov 18, 2026
Merged

nfebe merged 3 commits into
mainfrom
feat/event-primitives

Conversation

@nfebe

@nfebe nfebe commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Add reusable events and listeners for Python applications. Queue delivery through jobs so events can commit with application state.

@sourceant

sourceant Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Code Review Summary

The package adds event envelopes and isolated event buses with ordered, wildcard, contextual, synchronous, and asynchronous listener dispatch. Optional jobs integration serializes events for queued delivery, while signed HTTP provides a configurable outbound transport; queueing can use caller transaction context, and worker listener failures request retries.

🚀 Key Improvements

  • Events can be queued using the caller's transaction context.
  • Listener delivery supports ordered dispatch, wildcard subscriptions, and opt-in caller context.
  • Signed HTTP delivery and worker retry handling are available as optional integrations.

@sourceant sourceant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. See the overview comment for a summary.

raise ValueError("An event requires an identifier")
if not isinstance(self.data, Mapping) or not isinstance(self.metadata, Mapping):
raise ValueError("Event data and metadata must be mappings")
if (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A tzinfo object can be present while utcoffset() returns None, which means Python treats the datetime as naive. Such an event is accepted, then to_dict() converts it using the machine’s local timezone and can emit the wrong occurrence time; also reject datetimes whose utcoffset() is None.

Suggested change
if (
if (
not isinstance(self.occurred_at, datetime)
or self.occurred_at.tzinfo is None
or self.occurred_at.utcoffset() is None
):
raise ValueError("An event requires a timezone-aware occurrence time")

@sourceant sourceant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. See the overview comment for a summary.

@nfebe
nfebe merged commit 1c40f47 into main Nov 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant