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

[Workflows] Expose CancellationToken as part of RunAsync #1225

Open
clintsinger opened this issue Jan 12, 2024 · 3 comments
Open

[Workflows] Expose CancellationToken as part of RunAsync #1225

clintsinger opened this issue Jan 12, 2024 · 3 comments
Labels
kind/enhancement New feature or request P2

Comments

@clintsinger
Copy link

Describe the feature

Currently the CancellationToken isn't exposed by the RunAsync abstract method. Traditionally, async methods include the token to be passed to subsequent async calls.

While there isn't currently any support for cancellation tokens, there is discussion about introducing them in the future. Since including it as part of the method signature would be a breaking change, it would make sense to introduce it at this time, during the beta period, in preparation for future use. A CancellationToken.None can be passed for the time being.

The run method signatures should look like the following for workflows and activities respectively, with the interfaces also being modified accordingly.

public abstract class Workflow<TInput, TOutput> : IWorkflow
{
  public abstract Task<TOutput> RunAsync(WorkflowContext context, TInput input, CancellationToken cancellationToken);
}

public abstract class WorkflowActivity<TInput, TOutput> : IWorkflowActivity
{
  public abstract Task<TOutput> RunAsync(WorkflowActivityContext context, TInput input), CancellationToken cancellationToken);
}
@clintsinger clintsinger added the kind/enhancement New feature or request label Jan 12, 2024
@clintsinger clintsinger changed the title [Workflows] Expose CancellationToken as part of the RunAsync [Workflows] Expose CancellationToken as part of RunAsync Jan 12, 2024
@AceHack
Copy link

AceHack commented Feb 7, 2024

Yes Please

@cicoyle
Copy link

cicoyle commented Sep 12, 2024

cc @cgillum can you put a label for priority on this issue?

@cgillum cgillum added P1 and removed P1 labels Sep 13, 2024
@cgillum
Copy link
Contributor

cgillum commented Sep 13, 2024

For the sake of not creating APIs that we hope to implement (the future often plays out differently than how we expect), I would prefer we plan to add cancellation token support as a property of the context object rather than as a parameter in RunAsync. This would be a non-breaking change that we can implement when we're ready to do so.

For that reason, I suggest we make this a P2 for 1.15 with the intent of actually implementing cancellation (at least for workflow activities) rather than hardcoding it to CancellationToken.None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request P2
Projects
Status: Backlog
Development

No branches or pull requests

4 participants