dapr / dotnet-sdk

Dapr SDK for .NET
Apache License 2.0
1.12k stars 340 forks source link

Proposal: Support cancellation tokens for non-remoted actor interfaces #1201

Closed philliphoff closed 11 months ago

philliphoff commented 1 year ago

Describe the proposal

With #1158, actor clients would have the ability to create actor interfaces that support cancellation tokens, even if the interface used by the actor implementation did not. However, if the actor client interface does use cancellation tokens, the actor implementation cannot use that same interface for its own implementation, as the non-remoted actor proxy does not support them.

This proposal would add support for cancellation tokens in interfaces when invoking actors through the non-remoted actor proxy. Adding this support will allow actor implementations the option of sharing the same interfaces as generated clients and is a precursor to (future) support for the generation of actor implementations.

This support would allow methods of the forms:


public interface IMyActor : IActor
{
  Task NoArgumentsAsync();
  Task NoCancellationAsync(MyArgument argument);
  Task NoArgumentsButCancellationAsync(CancellationToken cancellationToken);
  Task OneArgumentAndCancellationAsync(MyArgument argument, CancellationToken cancellationToken);
}

:warning: The remoting-based actor proxy cannot be used with interfaces with cancellation tokens. That is, it is a non-goal (for now) to support cancellation tokens using remoting. Use of cancellation tokens would be an explicit choice for actors to always use non-remoting clients (such as the generated client interfaces).

philliphoff commented 12 months ago

/assign