feat(workflow): add WorkflowEventDispatcher + AddEscalatedWorkflows#20
Open
mpge wants to merge 1 commit intofeat/workflow-runnerfrom
Open
feat(workflow): add WorkflowEventDispatcher + AddEscalatedWorkflows#20mpge wants to merge 1 commit intofeat/workflow-runnerfrom
mpge wants to merge 1 commit intofeat/workflow-runnerfrom
Conversation
…xtension
Final piece of the workflow stack for .NET. Adds a decorator
IEscalatedEventDispatcher that, for every dispatched event:
1. Forwards to the host's inner dispatcher (so host subscribers see
every event in original order)
2. Resolves the event to a canonical workflow trigger name
3. Kicks WorkflowRunnerService.RunForEventAsync for matching triggers
Event → trigger mapping (matches WorkflowEngine.TRIGGER_EVENTS):
TicketCreatedEvent → ticket.created
TicketUpdatedEvent → ticket.updated
TicketStatusChangedEvent, → ticket.status_changed
TicketResolvedEvent,
TicketClosedEvent
TicketReopenedEvent → ticket.reopened
TicketAssignedEvent → ticket.assigned
TicketPriorityChangedEvent → ticket.priority_changed
DepartmentChangedEvent → ticket.department_changed
TagAddedEvent / TagRemoved → ticket.tagged
ReplyCreatedEvent → reply.created
SlaBreachedEvent → sla.breached
SlaWarningEvent → sla.warning
Runner failures are caught + ILogger-logged so a misbehaving workflow
never blocks the event that fired it.
Host apps opt in with:
services.AddEscalated().AddEscalatedWorkflows();
With this commit the chain is complete end-to-end:
TicketService mutation → IEscalatedEventDispatcher.DispatchAsync →
WorkflowEventDispatcher decorator → WorkflowRunnerService →
WorkflowEngine (conditions) + WorkflowExecutorService (actions) →
WorkflowLog audit row
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.
Summary
Final piece of the workflow stack for .NET. Adds a decorator
IEscalatedEventDispatcherthat, for every event dispatched by Escalated services:WorkflowRunnerService.RunForEventAsyncfor matching triggersEvent → trigger mapping
Matches
WorkflowEngine.TRIGGER_EVENTS:TicketCreatedEventticket.createdTicketUpdatedEventticket.updatedTicketStatusChangedEvent/TicketResolvedEvent/TicketClosedEventticket.status_changedTicketReopenedEventticket.reopenedTicketAssignedEventticket.assignedTicketPriorityChangedEventticket.priority_changedDepartmentChangedEventticket.department_changedTagAddedEvent/TagRemovedEventticket.taggedReplyCreatedEventreply.createdSlaBreachedEventsla.breachedSlaWarningEventsla.warningRunner failures are caught +
ILogger.LogError'd so a misbehaving workflow never blocks the event that fired it.Opt-in
Host apps wire this in once during
Program.cs:AddEscalatedWorkflows()is idempotent — calling it twice doesn't double-wrap.Complete chain
Dependencies
feat/workflow-runner), which is stacked on feat(workflow): add WorkflowExecutorService for action dispatch #18 (feat/workflow-executor).Test plan
[Theory]), inner-dispatcher forwarding, runner kick, unknown-event isolation, end-to-end workflow log creation against in-memory EF Core