0.1.34 • Published 4 years ago

clusterduck-redis v0.1.34

Weekly downloads
-
License
GPL-3.0-only
Repository
github
Last release
4 years ago

clusterduck-redis total downloads of clusterduck-redis

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

A Redis extension for Clusterduck which includes:

Table Of Contents

Installation

Clusterduck is required.

npm i -g clusterduck-redis

Configuration

Let's define a Redis cluster named my_redis_cluster:

# clusters:

my_redis_cluster:
  type: clusterduck-redis

Nodes

Then let's define some nodes:

    # List of nodes
    nodes:
      - addr: 127.0.0.1:6379
      - addr: 127.0.0.1:6380

Note that you can omit this altogether if you want to only add nodes dynamically.

Health checks

Now let's set up a simple health check.

    health_checks:

      - type: basic
        timeout: 1s
        every: 1s
        commands:
          - [ 'SET', 'x', 'y' ]

Now every second each node in the cluster will get checked on.

Envoy balancer

Envoy is required to be installed.

Let's write up a config:

  balancers:

    my_balancer:
      type: envoy
      listen: 0.0.0.0:9999

      # This section is optional
      admin:
        access_log_path: "/tmp/admin_access.log"
        address:
          socket_address:
            address: "127.0.0.1"
            port_value: 9901

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

Redis server wrapper

If you want to run multiple Redis instances you can use redis-server-wrapper to make life easier.

Let's start a Redis instance:

CLUSTER=redis_cache redis-server-wrapper start -d

It will pick an unused port from the range, spawn a Redis instance, and add the address to your Clusterduck cluster.

If you want to stop a Redis instance, just run clusterduck stop [port] and it will remove it from the cluster first, then wait a bit, so the traffic is off the instance and then gracefully shutdown Redis.

Debug

For debugging purposes use DEBUG environmental variable: DEBUG=ioredis*,envoy clusterduck

Cluster events

EventDescription
nodesSet of nodes has changed
activeSet of active nodes has changed

Node events

EventDescription
stateNode state has changed

Dependencies

Envoy balancer

License

LGPL 3.0 or later.

0.1.30

4 years ago

0.1.31

4 years ago

0.1.32

4 years ago

0.1.33

4 years ago

0.1.34

4 years ago

0.1.27

4 years ago

0.1.28

4 years ago

0.1.29

4 years ago

0.1.26

4 years ago

0.1.25

4 years ago

0.1.24

4 years ago

0.1.22

4 years ago

0.1.23

4 years ago

0.1.21

4 years ago

0.1.20

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago

0.1.16

4 years ago

0.1.17

4 years ago

0.1.15

4 years ago

0.1.11

4 years ago

0.1.12

4 years ago

0.1.13

4 years ago

0.1.14

4 years ago

0.1.10

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.9

4 years ago

0.1.6

4 years ago

0.1.4

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago