Skip to content

Commit

Permalink
Add support for Consul as store engine (#240)
Browse files Browse the repository at this point in the history
* Add support for Consul as store engine

* Update go.mod and docker compose

* Remove context from electLoop

* Update consul indirect dependency

* Add consul config file

* Update per comments
  • Loading branch information
borismartinovic01 authored Jan 7, 2025
1 parent 73081f4 commit 9b80970
Show file tree
Hide file tree
Showing 11 changed files with 692 additions and 85 deletions.
42 changes: 42 additions & 0 deletions config/config-consul.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

addr: "127.0.0.1:8500"


# Which store engine should be used by controller
# options: etcd, zookeeper, raft, consul
# Note: the raft engine is an experimental feature and is not recommended for production use.
#
# default: etcd
storage_type: consul

consul:
addrs:
- "127.0.0.1:8500"
elect_path:
tls:
enable: false
cert_file:
key_file:
ca_file:

controller:
failover:
ping_interval_seconds: 3
min_alive_size: 5
2 changes: 1 addition & 1 deletion config/config-raft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ addr: "127.0.0.1:9379"


# Which store engine should be used by controller
# options: etcd, zookeeper, raft
# options: etcd, zookeeper, raft, consul
# Note: the raft engine is an experimental feature and is not recommended for production use.
#
# default: etcd
Expand Down
2 changes: 1 addition & 1 deletion config/config-zk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ addr: "127.0.0.1:9379"


# Which store engine should be used by controller
# options: etcd, zookeeper, raft
# options: etcd, zookeeper, raft, consul
# Note: the raft engine is an experimental feature and is not recommended for production use.
#
# default: etcd
Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"os"
"strings"

"github.com/apache/kvrocks-controller/store/engine/consul"
"github.com/apache/kvrocks-controller/store/engine/raft"

"github.com/go-playground/validator/v10"
Expand Down Expand Up @@ -56,6 +57,7 @@ type Config struct {
Etcd *etcd.Config `yaml:"etcd"`
Zookeeper *zookeeper.Config `yaml:"zookeeper"`
Raft *raft.Config `yaml:"raft"`
Consul *consul.Config `yaml:"consul"`
Admin AdminConfig `yaml:"admin"`
Controller *ControllerConfig `yaml:"controller"`
}
Expand Down
2 changes: 1 addition & 1 deletion config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ addr: "127.0.0.1:9379"


# Which store engine should be used by controller
# options: etcd, zookeeper, raft
# options: etcd, zookeeper, raft, consul
# Note: the raft engine is an experimental feature and is not recommended for production use.
#
# default: etcd
Expand Down
23 changes: 18 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/go-redis/redis/v8 v8.11.5
github.com/go-resty/resty/v2 v2.12.0
github.com/go-zookeeper/zk v1.0.3
github.com/hashicorp/consul/api v1.31.0
github.com/olekukonko/tablewriter v0.0.5
github.com/prometheus/client_golang v1.11.1
github.com/spf13/cobra v1.8.0
Expand All @@ -26,6 +27,7 @@ require (
)

require (
github.com/armon/go-metrics v0.4.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand All @@ -35,7 +37,7 @@ require (
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/coreos/pkg v0.0.0-20230327231512-ba87abf18a23 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
Expand All @@ -45,6 +47,14 @@ require (
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
Expand All @@ -54,10 +64,12 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
Expand All @@ -71,9 +83,10 @@ require (
go.uber.org/goleak v1.3.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
Expand Down
Loading

0 comments on commit 9b80970

Please sign in to comment.