Open pablo-salad opened 5 months ago
Thank you for reporting. This is a good point. There needs to be a better way to accomplish this. I'll mark this as a feature enhancement for now. Ideally, we have a better way to flow cancellation along grain call chains in general. GrainCancellationToken
is not ideal. Ideally, we would support CancellationToken
itself, natively.
Ideally, we would support
CancellationToken
itself, natively.
This is important to us, do you have a strategy for this in mind and if so, would you elaborate? If possible we'd like to contribute this feature.
This is important to us, do you have a strategy for this in mind and if so, would you elaborate? If possible we'd like to contribute this feature.
The feature needs design work - scenarios/requirements could help to drive the design. Lifetime/scope management for the cancellation is the biggest issue. Eg, do we support cancelling a captured CancellationToken
after the sending call has completed? Some rough ideas:
CancellationToken
parameter passed as a method parameter and implement an optional "cancellable invokable" interface for the method, allowing the invocation to be canceled.CancellationToken
parameter is supported per method, at the parameter level (not nested in other objects).Register
for cancellation notifications.
ActivationData
(the grain context) and when it receives the call, it finds the relevant message and cancels its "cancellable invokable".
An unexpected behavior has been observed while working with IAsyncEnumerable and we try to cancel it. A method returning an IAsyncEnumerable, which internally fetches data from the Channel, encounters no issues to be cancelled when there is data in it. However, if the Channel is empty and the cancellation is requested, there is no execution of code block in the try/finally within the grain.
There is a demo repo to explain this problem in detail.
You'll find three branches detailing various attempts to resolve this issue during our testing phase:
We would greatly appreciate any assistance on this matter. Thank you!