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

Allow cancel Invocable with payload on ConsumeQueueOnShutdown #274

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

lengockyquang
Copy link

@lengockyquang lengockyquang commented Jan 17, 2022

Check if invocableWithParams is ICancellableTask, assign its token to give token source. Cancel it on ConsumeQueueOnShutdown

@jamesmh
Copy link
Owner

jamesmh commented Apr 23, 2022

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.

@jamesmh jamesmh closed this Apr 23, 2022
@jamesmh jamesmh reopened this Apr 23, 2022
@jamesmh
Copy link
Owner

jamesmh commented Apr 23, 2022

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 IQueue bool TryCancel(string uniqueIdentifier)?

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
@lengockyquang
Copy link
Author

Thanks for those reviews @jamesmh , I just add few commits. If you have freetime, please take a look for it :D

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.

2 participants