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

Feature Request: debouncing #27

Closed
jeromecoupe opened this issue Jan 27, 2020 · 5 comments
Closed

Feature Request: debouncing #27

jeromecoupe opened this issue Jan 27, 2020 · 5 comments

Comments

@jeromecoupe
Copy link

jeromecoupe commented Jan 27, 2020

Thank you for making this available to the community. The webhooks plugin is a big part of using Craft in a headless mode with Static Site Generators of all kinds. It makes triggering a build when an an element is created or edited relatively trivial.

However, when someone is making updates in the CP, it can trigger quite a few builds in a row, when only the last one is really needed.

I don't have the PHP skills to implement it or to assess how easy / difficult it is to implement but I think a debounce period before triggering the webhook would help tremendously. It can be set to 0 by default so it would not break any current implementations.

I also have a related question.

As I understood, Craft Cloud will not allow plugins. Since it would be a really competitive option IMHO compared to other Sass headless CMS out there, I was wondering if webhooks are going to become part of Craft Core or if you have something else in mind to replicate this type of functionality in Craft Cloud ?

@mattstein
Copy link
Contributor

+1 for this. I created a separate plugin that just sets a flag for cron, but this makes more sense as a feature for Webhooks and all the other benefits it provides.

@juddlyon
Copy link

juddlyon commented Apr 7, 2020

I'd love this as well. Currently I do a poor man's version of @mattstein's plugin by adding a bookmark to the CP sidebar. I tell users to click it once they're done editing and all it does is generate a Guzzle endpoint call.

@brandonkelly
Copy link
Member

Just added this for the next release! As of 2.3, webhooks will have a new “Debounce Key Format”, which can optionally be set to a Twig template that defines the “debounce key” for a webhook request.

If two webhooks get triggered around the same time that generate the same debounce key, only the second webhook will actually get sent.

The new “Debounce Key Format” setting

@mattstein mattstein changed the title Feeature Request: debouncing Feature Request: debouncing Jun 18, 2020
@brandonkelly
Copy link
Member

Webhooks 2.3.0 is out now!

@FreekVR
Copy link

FreekVR commented Mar 1, 2021

Just saw this, and just to make sure, the debouncing works by checking the queue. In other words, the time period within which new webhooks calls are debounced is however long a job with the same key is in the queue for?

Asking because I was trying to check this on my local environment, which is configured with "runTasksAutomatically" and debouncing did not have the desired effect there when quickly changing multiple entries.

Ideally one could set a certain debounce duration / job delay too, so that the webhook job would not be executed for that amount of time, otherwise the only way to set this is by having the whole queue crontab set to eg. */5 * * * * (affecting how often other jobs are picked up as well)

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

No branches or pull requests

5 participants