Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend kv.client storeconfig to support memberlist flags #621

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
* [CHANGE] memberlist: Failure to fast-join a cluster via contacting a node is now logged at `info` instead of `debug`. #585
* [CHANGE] `Service.AddListener` and `Manager.AddListener` now return function for stopping the listener. #564
* [CHANGE] ring: Add `InstanceRingReader` interface to `ring` package. #597
* [CHANGE] KV: Add `MemberlistKVConfig` at kv `StoreConfig`. Extended `RegisterFlagsWithPrefix` to populate `MemberlistKVConfig` flags with specific prefix. #621
* [FEATURE] Cache: Add support for configuring a Redis cache backend. #268 #271 #276
* [FEATURE] Add support for waiting on the rate limiter using the new `WaitN` method. #279
* [FEATURE] Add `log.BufferedLogger` type. #338
Expand Down
8 changes: 5 additions & 3 deletions kv/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ var (
// Consul, Etcd, Memberlist or MultiClient. It was extracted from Config to keep
// single-client config separate from final client-config (with all the wrappers)
type StoreConfig struct {
Consul consul.Config `yaml:"consul"`
Etcd etcd.Config `yaml:"etcd"`
Multi MultiConfig `yaml:"multi"`
Consul consul.Config `yaml:"consul"`
Etcd etcd.Config `yaml:"etcd"`
MemberlistKVConfig memberlist.KVConfig `yaml:"memberlist"`
Multi MultiConfig `yaml:"multi"`

// Function that returns memberlist.KV store to use. By using a function, we can delay
// initialization of memberlist.KV until it is actually required.
Expand Down Expand Up @@ -74,6 +75,7 @@ func (cfg *Config) RegisterFlagsWithPrefix(flagsPrefix, defaultPrefix string, f
cfg.Consul.RegisterFlags(f, flagsPrefix)
cfg.Etcd.RegisterFlagsWithPrefix(f, flagsPrefix)
cfg.Multi.RegisterFlagsWithPrefix(f, flagsPrefix)
cfg.MemberlistKVConfig.RegisterFlagsWithPrefix(f, flagsPrefix)

if flagsPrefix == "" {
flagsPrefix = "ring."
Expand Down
7 changes: 7 additions & 0 deletions kv/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ consul:
host: "consul:8500"
consistentreads: true
prefix: "test/"
memberlist:
node_name: "testNode"
randomize_node_name: false
stream_timeout: 3s
multi:
primary: consul
secondary: etcd
Expand All @@ -35,6 +39,9 @@ multi:
require.Equal(t, "consul", cfg.Store)
require.Equal(t, "test/", cfg.Prefix)
require.Equal(t, "consul:8500", cfg.Consul.Host)
require.Equal(t, "testNode", cfg.MemberlistKVConfig.NodeName)
require.Equal(t, false, cfg.MemberlistKVConfig.RandomizeNodeName)
require.Equal(t, 3*time.Second, cfg.MemberlistKVConfig.StreamTimeout)
require.Equal(t, "consul", cfg.Multi.Primary)
require.Equal(t, "etcd", cfg.Multi.Secondary)
}
Expand Down