clusterduck-http v0.1.8
clusterduck-http 
The HTTP extension for Clusterduck which includes:
- HTTP/WebSocket health checks
- Balancer: HAProxy integration with seamless hot restarting.
Table Of Contents
Installation
Clusterduck is required.
npm i -g clusterduck-httpConfiguration
Let's define a HTTP cluster named my_web_cluster:
# clusters:
my_http_cluster:
type: clusterduck-httpNodes
Then let's define some nodes:
# List of nodes
nodes:
- addr: 1.1.1.1:80
- addr: 2.2.2.2:80Note that you can omit this altogether if you want to only add nodes dynamically.
Health checks
If you do not want to use health checks, use:
pass_without_checks: trueOtherwise, define the health_checks array:
health_checks:WebSocket
- type: websocket
timeout: 5s
every: 10s
url: wss://your-domain/websocket/
every: 1000s
timeout: 20s
flow:
- type: expect_json # Expect a JSON packet
skip_forward: true # Ignore prior unexpected packets
match: # Match conditions [path, eq|exists, ?right]
- [ response.text, eq, "Knock-knock."]
- [ timestamp ] # 'timestamp' field exists
- type: send_json
body: {query: {text: "Who's there?"}}
- type: expect_json
match:
- [ response.text, eq, "Amish."]
- type: send_json
body: {query: {text: "Amish who?"}}
- type: expect_json
match:
- [ response.text, eq, "Really? You don’t look like a shoe!"]Note that DNS lookups get overridden, so
your-domainwill be resolved to an IP-address corresponding to one of the nodes in your cluster. However,Hostheader will be set toyour-domain.
HAProxy balancer
HAProxy is required to be installed.
Let's write up a config:
balancers:
my_balancer:
type: haproxy
listen: 0.0.0.0:443Note:
clusterduckwill runhaproxywith an according configuration. Hot restarting works out-of-box so thatHAProxyis always kept in sync withclusterduck. It requires no middleware or additional configuration.
Debug
For debugging purposes use DEBUG environmental variable:
DEBUG=haproxy clusterduck
Dependencies
HAProxy balancer
License
LGPL 3.0 or later.