-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Optimise webhook events #9168
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
Optimise webhook events #9168
Conversation
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
✨ Benchmark results
⚡ Benchmark Comparison
|
$queueForRealtime | ||
->from($queueForEvents) | ||
->trigger(); | ||
/** Trigger realtime events only for non console events */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the console also uses realtime events, or those are all associated with a specific project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't fire realtime events for DOCUMENT_CREATE events fired from the console. This is the existing behaviour. I have not changed it.
https://github.com/appwrite/appwrite/blob/1.6.x/app/controllers/shared/api.php#L81-L88
https://github.com/appwrite/appwrite/blob/1.6.x/app/controllers/shared/api.php#L529-L536
app/controllers/shared/api.php
Outdated
if ($queueForEvents->getProject()->getId() === 'console') { | ||
return; | ||
/** Trigger webhooks events only if a project has them enabled */ | ||
if ($project->getAttribute('webhooks', []) !== []) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to go deeper and check if the specific even is listened by the webhooks? we should have the list of affected events in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this PR do?
Perviously all endpoints with an event, triggered webhooks events which resulted in the a lot of spurious events in the webhooks queue and causing redis memory usage to increase.
In this PR we check if the project has webhooks enabled and only then trigger the event.
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)
Related PRs and Issues
Checklist