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

Asynchronous Activities #3386

Merged
merged 11 commits into from
Oct 27, 2022
Merged

Asynchronous Activities #3386

merged 11 commits into from
Oct 27, 2022

Conversation

sfmskywalker
Copy link
Member

This PR adds the ability for activities to execute asynchronously, which means, in the background without blocking workflow execution of other activities.

This enables scenarios where you have for example two branches that each execute an activity that then execute in the background in parallel.

Before this PR, one would have to create an activity that does the following:

  1. Start a background job that performs the real work;
  2. Suspend itself;
  3. When the background job completes, resume the activity.

After this PR, we can now simply write an activity and configure its Kind to be either Job or Task.

When configured as Job, the activity will always execute in the background.
When configured as Task, the activity will execute in the foreground by default, but allows the user to configure the activity to run in the background instead.

As an example, the SendHttpRequest activity has its Kind set to Task, allowing users of this activity to either execute the activity in the foreground or in the background.

When running the activity in the foreground, the workflow engine cannot run other activities. This means that even if you have a fork with e.g. 3 branches, each branch performing an HTTP request that takes e.g. 2 seconds, it would take a total of 6 seconds for all branches to complete.

But when you run the activities in the background, they can execute in parallel, allowing the fork to finish in 2 seconds.

@sfmskywalker sfmskywalker merged commit c6bfd1f into v3 Oct 27, 2022
@sfmskywalker sfmskywalker deleted the v3-background-activities branch October 27, 2022 10:05
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