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
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
8 changes: 7 additions & 1 deletion .github/workflows/ci-it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ jobs:
run: |
echo $GOARCH
go test -cpu=2 -timeout 10s -race -coverprofile=coverage.txt -covermode=atomic ./...
bash <(curl -s https://codecov.io/bash)
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: .
fail_ci_if_error: true
flags: by-github-actions
CODE-CHECK:
runs-on: ubuntu-latest
container:
Expand Down
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 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 @@
if p.Cfg.SyncConnect {
config.DialOptions = append(config.DialOptions, grpc.WithBlock())
}
if p.Cfg.AutoSyncInterval > 0 {
config.AutoSyncInterval = p.Cfg.AutoSyncInterval

Check warning on line 93 in providers/etcd/etcd.go

View check run for this annotation

Codecov / codecov/patch

providers/etcd/etcd.go#L92-L93

Added lines #L92 - L93 were not covered by tests
}
if p.Cfg.MaxCallSendMsgSize > 0 {
config.MaxCallSendMsgSize = p.Cfg.MaxCallSendMsgSize

Check warning on line 96 in providers/etcd/etcd.go

View check run for this annotation

Codecov / codecov/patch

providers/etcd/etcd.go#L95-L96

Added lines #L95 - L96 were not covered by tests
}
if p.Cfg.MaxCallRecvMsgSize > 0 {
config.MaxCallRecvMsgSize = p.Cfg.MaxCallRecvMsgSize

Check warning on line 99 in providers/etcd/etcd.go

View check run for this annotation

Codecov / codecov/patch

providers/etcd/etcd.go#L98-L99

Added lines #L98 - L99 were not covered by tests
}
if p.Cfg.RejectOldCluster {
config.RejectOldCluster = p.Cfg.RejectOldCluster

Check warning on line 102 in providers/etcd/etcd.go

View check run for this annotation

Codecov / codecov/patch

providers/etcd/etcd.go#L101-L102

Added lines #L101 - L102 were not covered by tests
}
if p.Cfg.PermitWithoutStream {
config.PermitWithoutStream = p.Cfg.PermitWithoutStream

Check warning on line 105 in providers/etcd/etcd.go

View check run for this annotation

Codecov / codecov/patch

providers/etcd/etcd.go#L104-L105

Added lines #L104 - L105 were not covered by tests
}
if p.Cfg.BackoffWaitBetween > 0 {
config.BackoffWaitBetween = p.Cfg.BackoffWaitBetween

Check warning on line 108 in providers/etcd/etcd.go

View check run for this annotation

Codecov / codecov/patch

providers/etcd/etcd.go#L107-L108

Added lines #L107 - L108 were not covered by tests
}
if p.Cfg.BackoffJitterFraction > 0 {
config.BackoffJitterFraction = p.Cfg.BackoffJitterFraction

Check warning on line 111 in providers/etcd/etcd.go

View check run for this annotation

Codecov / codecov/patch

providers/etcd/etcd.go#L110-L111

Added lines #L110 - L111 were not covered by tests
}
return clientv3.New(config)
}

Expand Down
Loading