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: support all etcd client configs #322

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Changes from 1 commit
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
34 changes: 31 additions & 3 deletions providers/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ type Interface interface {
}

type config struct {
Endpoints string `file:"endpoints" env:"ETCD_ENDPOINTS"`
Timeout time.Duration `file:"timeout" default:"5s"`
TLS struct {
Endpoints string `file:"endpoints" env:"ETCD_ENDPOINTS"`
Timeout time.Duration `file:"timeout" default:"5s"`
AutoSyncInterval time.Duration `file:"auto_sync_interval" env:"ETCD_AUTO_SYNC_INTERVAL"`
MaxCallSendMsgSize int `file:"max_call_send_msg_size" env:"ETCD_MAX_CALL_SEND_MSG_SIZE"`
MaxCallRecvMsgSize int `file:"max_call_recv_msg_size" env:"ETCD_MAX_CALL_RECV_MSG_SIZE"`
RejectOldCluster bool `file:"reject_old_cluster" env:"ETCD_REJECT_OLD_CLUSTER"`
PermitWithoutStream bool `file:"permit_without_stream" env:"ETCD_PERMIT_WITHOUT_STREAM"`
BackoffWaitBetween time.Duration `file:"backoff_wait_between" env:"ETCD_BACKOFF_WAIT_BETWEEN"`
BackoffJitterFraction float64 `file:"backoff_jitter_fraction" env:"ETCD_BACKOFF_JITTER_FRACTION"`
TLS struct {
CertFile string `file:"cert_file"`
CertKeyFile string `file:"cert_key_file"`
CaFile string `file:"ca_file"`
Expand Down Expand Up @@ -82,6 +89,27 @@ func (p *provider) Connect() (*clientv3.Client, error) {
if p.Cfg.SyncConnect {
config.DialOptions = append(config.DialOptions, grpc.WithBlock())
}
if p.Cfg.AutoSyncInterval > 0 {
config.AutoSyncInterval = p.Cfg.AutoSyncInterval
}
if p.Cfg.MaxCallSendMsgSize > 0 {
config.MaxCallSendMsgSize = p.Cfg.MaxCallSendMsgSize
}
if p.Cfg.MaxCallRecvMsgSize > 0 {
config.MaxCallRecvMsgSize = p.Cfg.MaxCallRecvMsgSize
}
if p.Cfg.RejectOldCluster {
config.RejectOldCluster = p.Cfg.RejectOldCluster
}
if p.Cfg.PermitWithoutStream {
config.PermitWithoutStream = p.Cfg.PermitWithoutStream
}
if p.Cfg.BackoffWaitBetween > 0 {
config.BackoffWaitBetween = p.Cfg.BackoffWaitBetween
}
if p.Cfg.BackoffJitterFraction > 0 {
config.BackoffJitterFraction = p.Cfg.BackoffJitterFraction
}
return clientv3.New(config)
}

Expand Down
Loading