Repository navigation
Deliver events to handlers in every deployment (#327) - #339
Merged
Merged
Conversation
PgBossEventBus only fanned events out to handlers registered in its own process, so with DISABLE_EMBEDDED_WORKERS=true every event the API published was recorded and then delivered nowhere. A process that runs no handlers now puts events on an evt.__dispatch queue, and every process that has started handlers consumes it and fans them out to its handler queues. This also covers WORKER_MODE=integrations workers. The standalone worker now sets up the same DI container as the API (queue adapter, event bus, full command bus, delivery and arrival services) instead of hand-built command buses, and both processes register the event handlers with the full command bus. The command-driven handlers (issue engine, auto-replenishment, route planning) therefore run in both setups, whether or not an LLM is configured. Replaces the route-planning-only workaround from #336. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #327.
What changed
PgBossEventBusused to fan events out only to handlers registered in its own process, so withDISABLE_EMBEDDED_WORKERS=trueevery event the API published was recorded and delivered nowhere. A process that runs no handlers now puts events onevt.__dispatch; every process that has started handlers consumes it and fans the events out to its own handler queues. pg-boss delivers each job once, so nothing is handled twice, including with several workers. This also coversWORKER_MODE=integrations.Behaviour change: in the default embedded dev setup, the issue engine and auto-replenishment now run (they were silently skipped before). The triage agent still needs an LLM provider.
Testing
PgBossEventBustests: dispatch from a non-consuming process, direct fan-out from a consuming one, fan-out of dispatched events, and no consuming with zero handlers.tsc, tenancy and boundary lints pass.DISABLE_EMBEDDED_WORKERS=trueplus aWORKER_MODE=allworker. A shipment created through the API got its read-model row and timeline entry within ~2s, via the dispatch queue, and the worker ran route planning. In embedded mode, events still fan out directly, with no dispatch job and no duplicate timeline entry.🤖 Generated with Claude Code