Skip to content

openach/webhook-queue-redis

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webhook Queue API

This is a prototype for a webhook queue, with a simple REST/JSON API for adding webhook calls to a queue, and a worker that executes the webhook requests.

Installation

Using docker-compose, simply clone this repository and run:

docker-compose up -d

The API will be available on localhost port 80:

http://localhost/api/

To shut down the application, run:

docker-compose down

Adding Webhooks to the Queue

To add a webhook to the queue, POST a request to http://localhost/api/ with the following parameters:

  • url - The URL of the webhook
  • method - Either GET or POST
  • params - A JSON formatted object of key: value pairs representing the parameters to be passed with the webhook request
  • cb - An optional URL to be called if the webhook call fails. This will be a simple GET request.

Make sure that your request specifies x-www-form-urlencoded for the body encoding.

How it Works

Calling the API adds your webhook request to a queue (managed on a Redis instance). A worker thread picks up the requests from the queue and executes them. Each request is attempted 10 times, and if the HTTP status code of the response is < 200 or >= 300, a GET request will be made to the cb url (assuming it is set).

Credits

This application is based on this post blog post: http://anandmanisankar.com/posts/docker-container-nginx-node-redis-example/

About

Sample docker workflow with Node.js, Redis and NGiNX

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 87.8%
  • Nginx 12.2%