Skip to content

Commit

Permalink
Add redis as storage backend
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalcrab committed May 9, 2018
1 parent b560f1f commit 2305442
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 5 deletions.
16 changes: 15 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Options:
key/value tag pairs to the given node.
-keyspace=dkron The keyspace to use. A prefix under all data is stored
for this instance.
-backend=[etcd|consul|zk] Backend storage to use, etcd, consul or zookeeper. The default
is etcd.
-backend=[etcd|consul|zk|redis] Backend storage to use, etcd, consul, zk (zookeeper) or redis.
The default is etcd.
-backend-machine=127.0.0.1:2379 Backend storage servers addresses to connect to. This flag can be
specified multiple times.
-encrypt Key for encrypting network traffic.
Expand Down
4 changes: 3 additions & 1 deletion dkron/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
"github.com/abronan/valkeyrie"
"github.com/abronan/valkeyrie/store"
"github.com/abronan/valkeyrie/store/consul"
etcd "github.com/abronan/valkeyrie/store/etcd/v2"
"github.com/abronan/valkeyrie/store/etcd/v2"
"github.com/abronan/valkeyrie/store/redis"
"github.com/abronan/valkeyrie/store/zookeeper"
"github.com/victorcoder/dkron/cron"
)
Expand Down Expand Up @@ -50,6 +51,7 @@ func init() {
etcd.Register()
consul.Register()
zookeeper.Register()
redis.Register()
}

func NewStore(backend string, machines []string, a *Agent, keyspace string, config *store.Config) *Store {
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ services:
- "2181"
hostname: node1

redis:
image: redis
ports:
- "6379"

dkron:
build: .
depends_on:
- consul
- etcd
- zk
- redis
ports:
- "8080"
- "8946"
Expand All @@ -43,3 +49,5 @@ services:
# command: scripts/entrypoint.sh agent -server -backend=etcd -backend-machine=etcd:2379 -join=dkron:8946 -log-level=debug
# Uncomment to use zk
# command: scripts/entrypoint.sh agent -server -backend=zk -backend-machine=zk:2181 -join=dkron:8946 -log-level=debug
# Uncomment to use redis
# command: scripts/entrypoint.sh agent -server -backend=redis -backend-machine=redis:6379 -join=dkron:8946 -log-level=debug
6 changes: 6 additions & 0 deletions scripts/test-infra/dd-conf/redis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
init_config:

instances:
- host: redis0
port: 6379
timeout: 3
31 changes: 31 additions & 0 deletions scripts/test-infra/redis
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

docker service rm redis0

docker service create \
--name redis0 \
--network my-net \
redis

sleep 10

docker service rm dkron-redis0 dkron-redis

docker service create \
--name dkron-redis0 \
--network my-net \
--publish 8090:8080 \
--container-label beta="0" \
dkron/dkron:v0.9.3 \
agent -server -bind=0.0.0.0:8946 -backend=redis -backend-machine=redis0:6379 -join=dkron-redis0:8946 -dog-statsd-addr=dd-agent:8125 -log-level=debug

sleep 5

docker service create \
--name dkron-redis \
--network my-net \
--replicas 5 \
--publish 8091:8080 \
--container-label beta="0" \
dkron/dkron:v0.9.3 \
agent -server -bind=0.0.0.0:8946 -backend=redis -backend-machine=redis0:6379 -join=dkron-redis0:8946 -dog-statsd-addr=dd-agent:8125 -log-level=debug
2 changes: 1 addition & 1 deletion website/content/basics/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Settings for dkron can be specified in three ways: Using a `config/dkron.json` c

* `-http-addr` - The address where the web UI will be binded. By default `:8080`

* `-backend` - Backend storage to use, etcd, consul or zk (zookeeper). The default is etcd.
* `-backend` - Backend storage to use, etcd, consul, zk (zookeeper) or redis. The default is etcd.

* `-backend-machine` - Backend storage servers addresses to connect to. This flag can be specified multiple times. By default `127.0.0.1:2379`

Expand Down

0 comments on commit 2305442

Please sign in to comment.