-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
Allow cancel Invocable with payload on ConsumeQueueOnShutdown #274
base: master
Are you sure you want to change the base?
Conversation
Thanks for this! I'm actually thinking about re-working some of the queuing API significantly to be able handle cases where, let's say, an invocable that can be queued with a payload and is cancellable and [other things]. This will be coupled with other features like multiple queues. |
Src/UnitTests/CoravelUnitTests/Queuing/CancellableInvocableForQueueTests.cs
Outdated
Show resolved
Hide resolved
Src/UnitTests/CoravelUnitTests/Queuing/CancellableInvocableForQueueTests.cs
Outdated
Show resolved
Hide resolved
If you're still up to it, let's get these changes in. I do have ideas long term like I mentioned, but these changes here are good. Did you also want to add a new method to Would look something like (this is all off the top of my head - there might some methods that aren't exact! lol) public bool TryCancel(string uniqueIdentifier)
{
if(this._tokens.TryGet("uniqueIdentifier", out var token))
{
if(!token.IsCancellationRequested)
{
token.Cancel();
return true;
}
}
return false;
// Note: the tokens that are cancelled with be cleaned whenever the queue runs. No need to clear them out.
} |
- Test IQueue TryCancelInvocable - Minor refactor on CanCancelInvocableWithPayloadOnQueueShutdown
Thanks for those reviews @jamesmh , I just add few commits. If you have freetime, please take a look for it :D |
Check if invocableWithParams is ICancellableTask, assign its token to give token source. Cancel it on ConsumeQueueOnShutdown