danielgerlag / danielgerlag/workflow-core
Workflow host Publish Event - Get specific execution pointer for comparing with Step Completed Life Cycle Event
- Dominant language
- C#
- Stars
- 5.9k
- Forks
- 1.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 5
Description
**Is your feature request related to a problem? Please describe.**
I have some workflow steps that should trigger an event/delegate back to a UI to display data that has been processed instead of polling for the data which can get costly. Is there an easy way to do this?
**Describe the solution you'd like**
Some of my workflow steps need to ping back to my UI to refresh so that data can be seen. I would like a way to know when a specific step has completed from a `PublishEvent`
Sort of something like this:
```
public string EventDrivenExecutionPointerId { get; set; }
// Blazor OnInitializedAsync
workflowHost.OnLifeCycleEvent += lifeCycleEvent =>
{
logger.LogInformation("Life cycle event: {@LifeCycleEvent}", lifeCycleEvent);
if (lifeCycleEvent is StepCompleted stepCompleted && stepCompleted.ExecutionPointerId == EventDrivenExecutionPointerId)
{
// Blazor UI Update
StateHasChanged();
}
};
EventDrivenExecutionPointerId = await workflowHost.PublishEvent("MyEvent", "0", "hello"); // wfc.ExecutionPointer.Id (GUID)
```
**Describe alternatives you've considered**
1. Tried passing an `Action` delegate to my `TSettings` for `IWorkflow`
- Causes NewtonSoft JSON.Net self reference loop error
2. Using a Scoped DI service
- Workflow steps do not pickup the scoped configured service that was instantiated on page initialize
3. Subscribe to `WorkflowHost.OnLifeCycleEvent`
- Not sure how to filter for the specific ExecutionPointerId of the step I am waiting for completion
**Additional context**
- MSSQL persistence
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the PublishEvent entry point, WorkflowHost.OnLifeCycleEvent, and the StepCompleted event mentioned in the issue; trace how execution pointer IDs are created and exposed. Check the MSSQL persistence path as needed. Done means a caller can identify the specific step completion from the published event without polling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100