Mailing List Archive

Implementing Webhooks.
I'm running Catalyst under mod_perl2 (currently, subject to change). Some
requests trigger a callback to a user-provided URL -- a webhook.

Obviously, it's best to do those asynchronously and not in-process. Don't
want a web request (or really an Apache process) hanging while waiting on
an external web server to respond.

A queue is probably the best approach, but there's also some advantage of
having the Catalyst app make the webhook request -- specifically because
the Catalyst app has the context of the request and has application logging
available.

How would you implement this?


How would that change if you wanted more than just "fire-and-forget"? For
example, if you wanted to provide some kind of retry interval for failed
callbacks. The external server might be temporarily down for maintenance.


Thanks,


--
Bill Moseley
moseley@hank.org
Re: Implementing Webhooks. [ In reply to ]
My take on this is to log things into ZeroMQ (via Message::Passing), and route them to Message::Passing::Output::WebHooks - the code for that output might not be as bullet proof as you’re looking for, but it should be a reasonable starting place.

I’d probably go right ahead and implement the timeout in that output for a first take - you’d lose anything which was waiting in a retry interval as and when you restarted the hook server, but that would presumably be very infrequently, and if you had _lots_ of timeouts, it could use a lot of RAM.. But depending upon that scale / relaibility you actually need both of these things might be just fine.

Cheers
Tom

On Jan 15, 2014, at 7:28 PM, Bill Moseley <moseley@hank.org> wrote:

> I'm running Catalyst under mod_perl2 (currently, subject to change). Some requests trigger a callback to a user-provided URL -- a webhook.
>
> Obviously, it's best to do those asynchronously and not in-process. Don't want a web request (or really an Apache process) hanging while waiting on an external web server to respond.
>
> A queue is probably the best approach, but there's also some advantage of having the Catalyst app make the webhook request -- specifically because the Catalyst app has the context of the request and has application logging available.
>
> How would you implement this?
>
>
> How would that change if you wanted more than just "fire-and-forget"? For example, if you wanted to provide some kind of retry interval for failed callbacks. The external server might be temporarily down for maintenance.
>
>
> Thanks,
>
>
> --
> Bill Moseley
> moseley@hank.org
> _______________________________________________
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/