-
Notifications
You must be signed in to change notification settings - Fork 429
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
feat: Add backoff to webhooks, and call multiple webhooks async #2559 #2783
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@tushar5526 is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
Some tests will fail, I will fix them after getting this approach reviewed. @gagantrivedi @matthewelwell you can check the latest commit to see the major changes of scheduling retries as a task in task processor. |
Uffizzi Preview |
@tushar5526 thanks for this. It seems quite complicated to me, however. I think we can ignore the need to support multiple backoff algorithms and just pick on that we think fits (my preference would be some kind of exponential algorithm I think). Perhaps I am over simplifying it, but I was imagining that we could achieve this functionality by just wrapping the task which calls the webhook in a I've not really been able to follow the code in this PR to understand the approach you've taken. Could you add a more detailed description of the approach to the summary of this PR? |
Agreed, I tried a similar approach in this PR. Let me describe it briefly. This PR majorly does the following. Provide both async and sync variants for
Now some kind of recursive logic is needed to keep scheduling the tasks for retries according to the specified backoffs and jitter techniques. For this, the There is one function to calculate the next delay (backoff + jitter time). Overall 2 main functions from user's point of view that can be used to call webhooks.
Example of how can we call the former.
I generalised the code to use any back-off strategy as I was unsure of which one would work better in this case, an agreed with sticking to any single approach to reduce complexity. PS: In my understanding, we can't get the return values of scheduled tasks in the task processor, so each scheduled task for retrying a webhook should contain the state of how many retries have happened so far. Also, it might help to review the PR in the unified view as the split view is indeed confusing. You can use this link. |
@matthewelwell should I scrape this PR and make a new one with a simpler implementation? |
@tushar5526 If there is a simpler way to implement it then yes, please - sorry, I haven't really had a chance to go over this PR again since your latest explanation. |
Sure! I will share a simpler implementation then. |
@matthewelwell here is a simpler implementation - #2932. Closing this one. |
Closes #1654
Thanks for submitting a PR! Please check the boxes below:
pre-commit
to check lintingChanges
Use a task processor to schedule each backoff as a task instead of retrying in a single task.
Also, I tried re-using the
backoff
library to have support for differentbackoff
andjitter
options supported in backoff.How did you test this code?
Ran a task processor and the master server, set up some faulty webhooks and called them.