dapr / dapr/dotnet-sdk

[Workflows] Expose CancellationToken as part of RunAsync

Open
#1,225 3 comments 3 reactions 0 assignees View on GitHub
kind/enhancement P2
Dominant language
C#
Stars
1.2k
Forks
378
Avg merge
2d 1h
Merged PRs (30d)
6

Description

## 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 : IWorkflow
{
public abstract Task RunAsync(WorkflowContext context, TInput input, CancellationToken cancellationToken);
}

public abstract class WorkflowActivity : IWorkflowActivity
{
public abstract Task RunAsync(WorkflowActivityContext context, TInput input), CancellationToken cancellationToken);
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.