clusterduck-http

0.1.8 • Public • Published

clusterduck-http total downloads of clusterduck-http

clusterduck-http's License latest version of clusterduck-http

The HTTP extension for Clusterduck which includes:

Table Of Contents

Installation

Clusterduck is required.

npm i -g clusterduck-http

Configuration

Let's define a HTTP cluster named my_web_cluster:

# clusters:

my_http_cluster:
  type: clusterduck-http

Nodes

Then let's define some nodes:

    # List of nodes
    nodes:
      - addr: 1.1.1.1:80
      - addr: 2.2.2.2:80

Note 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: true

Otherwise, 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-domain will be resolved to an IP-address corresponding to one of the nodes in your cluster. However, Host header will be set to your-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:443

Note: clusterduck will run haproxy with an according configuration. Hot restarting works out-of-box so that HAProxy is always kept in sync with clusterduck. It requires no middleware or additional configuration.

Debug

For debugging purposes use DEBUG environmental variable: DEBUG=haproxy clusterduck

Dependencies

  • clusterduck

HAProxy balancer

License

LGPL 3.0 or later.

Package Sidebar

Install

npm i clusterduck-http

Weekly Downloads

4

Version

0.1.8

License

GPL-3.0-only

Unpacked Size

52.6 kB

Total Files

7

Last publish

Collaborators

  • kakserpom