webhook-consumer

module
v0.0.0-...-c53e812 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2021 License: Apache-2.0

README

Webhook Consumer

The purpose of the Webhook Consumer is to provide a easy way to consume the notifications from the Stone services.

Image of webhook consumer diagram

Possible actions when receives a notification

When the Webhook Consumer receives a notification from Stone services, it can take some of the following actions:

  • Sends the notification to stdout (just for development)
  • Sends the notification to another API
  • Stores the notification on a Redis
  • Sends the notification to a Kafka topic

Current state

At this time, this project does not have a stable release.

Development

To init the development environment and runs the project, follow these steps:

Clone this repo
$ git clone git@github.com:stone-co/webhook-consumer.git
Download and install the dependency tools
$ make setup
Run the tests (optional)
$ make test
Compile the project
$ make compile
Run the project
$ ./build/webhook-consumer

Usage

At this time, just a simple notifier was implemented (stdout). After start the webhook, is possible to make a call and the data will be printed on the stdout.

Notifier List:

  • stdout
  • http proxy
  • redis

You can implements a notifier and submit a Pull Request, or showing interest by creating an issue with the type of notifier

Setup

Define PORT environment variable to Open Banking Organization send messages to Webhook Consumer, and customize shutdown timeout with API_SHUTDOWN_TIMEOUT. The defaults values are 3000 and 5s.

The environment variable PRIVATE_KEY_PATH contains a path to your key file, your private key made to Open Banking Partner, and PUBLIC_KEY_PATH identify the location of public key from Open Banking Organization.

The environment variable NOTIFIER_LIST must be a string, with notifiers name separated by ; character.

$ NOTIFIER_LIST="stdout;proxy;redis"

If you use http proxy as a notifer you must set the following environment variables:

  • PROXY_NOTIFIER_URL
  • PROXY_NOTIFIER_TIMEOUT (default = 10s)

If you use redis as a notifer you must set the following environment variables:

  • REDIS_ADDR required
  • REDIS_PORT required
  • REDIS_PASSWORD
  • REDIS_USE_TLS default false
  • REDIS_MAX_IDLE default 100
  • REDIS_MAX_ACTIVE default 1000
  • REDIS_IDLE_TIMEOUT default 1m
  • REDIS_CONNECT_TIMEOUT default 1s
  • REDIS_READ_TIMEOUT default 300ms
  • REDIS_WRITE_TIMEOUT default 300ms

Check configure notifer files to view all environment variables:

Usage with Docker

First build the Docker Image, or get at Docker Hub.

$ make build

Now create a container with volume to your certificate file, and a environment variable PRIVATE_KEY_PATH to your .pem file.

$ docker run -v $(pwd)/tests:/usr/share/certificates -e PRIVATE_KEY_PATH="/usr/share/certificates/partner/fakekey.pem" -d stone-co/webhook-consumer:dev

Environment variables, and default values:

you can pass environment variable with -e flat to docker container run.

-e API_PORT="3000"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL