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

Adds cancellation token support for long running work grains. #53

Merged
merged 5 commits into from
Feb 10, 2024

Conversation

Kritner
Copy link
Member

@Kritner Kritner commented Feb 3, 2024

Description

This is a breaking change to the package, as now implementations of grains need to have the additional parameter of GrainCancellationToken added.

Previous signature that needed implementing:

protected abstract Task<TResult> PerformWork(TRequest request);

New signature:

protected abstract Task<TResult> PerformWork(
  TRequest request, GrainCancellationToken grainCancellationToken);

You will be safe to just add this parameter to all of your long running grain implementations, but now you have the option of performing cancellation logic (added a few tests to demonstrate this)

  • CancellationTokens now provided to sync work grain execution through a Start overload.
  • Old Start method is still available, and just news up a cancellation token for backwards compatibility.
  • Grain implementations can decide what to do (or not) when a cancellation signal is received.
    • This could be to return an intermediate (but perhaps incomplete?) result, or throw.

Fixes #50

Type of Change

Use an x in between the [ ] for each line applicable to the type of change for this PR

  • Bug fix
  • New Feature
  • Documentation
  • Code improvement
  • Breaking change - if a public API changes, or any change that DOES or MAY require a major revision to the NuGet package version due to semver.
  • Unit tests
  • Code samples
  • Added your repository URL to the readme because you make use of this super cool package! ;)
  • Other

Describe testing that was performed for your change

New unit tests against cancellation token support

  • Can return a value as handling for cancellation
  • Can throw as handling for cancellation

Checklist

* Fixes #50
* CancellationTokens now provided to sync work grain execution through a `Start` overload.
* Old `Start` method is still available, and just news up a cancellation token for backwards compatibility.
* Grain implementations can decide what to do (or not) when a cancellation signal is received.
  * This could be to return an intermediate (but perhaps incomplete?) result, or throw.
@Kritner
Copy link
Member Author

Kritner commented Feb 3, 2024

This unfortunately is a breaking change in that the original abstract method to be implemented:

protected abstract Task<TResult> PerformWork(TRequest request);

has been changed to:

protected abstract Task<TResult> PerformWork(
  TRequest request, GrainCancellationToken grainCancellationToken);

This should be a minimally breaking change, but it is a breaking change nonetheless.

Not totally sure what to do regarding breaking changes in relationship to package versioning, since a breaking change warrants a major version increment, but was trying to keep the major version in line with the Orleans version... :X

@Kritner
Copy link
Member Author

Kritner commented Feb 3, 2024

Added some info and a poll to #54.

Don't know if it will get any responses since not really sure who is using the package, but will at a minimum wait a while to hear feedback.

@Kritner Kritner merged commit 135ad58 into main Feb 10, 2024
3 checks passed
@Kritner Kritner deleted the feature/50/cancellationToken branch February 10, 2024 13:33
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.

Add cancellation token support
1 participant