Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exportable & importable workflow state + execution #3317

Merged
merged 2 commits into from
Oct 4, 2022

Conversation

sfmskywalker
Copy link
Member

This PR adds support for the workflows runtime to export a given workflow's state so that it can be executed "in-process".

This enables scenarios where a workflow needs access to the HTTP context. Depending on the runtime, this may or may not be accessible.

For example, the Proto Actor workflow runtime implementation executes workflows in virtual actors (grains) which you can think of as being background processes which do not have access to HTTP response contexts when e.g. the workflow is triggered from an HTTP request.

The solution chosen here is to let the workflow execute in the grain until the WriteHttpResponse activity is encountered, which internally checks to see if it is executing within an HTTP context (which is not the case for grains). If this is not the case, the activity creates a resumable bookmark.

It is then up to the workflow invoker to identify these bookmarks and resume the workflow "externally" by exporting the workflow state from the runtime, resuming the workflow using the bookmarks, and then importing the state again.

One final improvement to be considered is to implement a locking mechanism to avoid workflow state concurrency issues. For example, it is possible that a workflow has a Delay activity that triggers at the time where the workflow state was exported and is executed outside of the grain. If the exported state is then imported, that state will be "stale" since the grain's internal workflow state will have been updated since the export.

Instead of locking, we could also consider merging states.

@sfmskywalker sfmskywalker merged commit 4b0af64 into v3 Oct 4, 2022
@sfmskywalker sfmskywalker deleted the v3-http-response-activity branch October 4, 2022 09:57
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