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

slack-vitess-r12.0.5: allow conn overrides in consul topo #108

Merged
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
12 changes: 9 additions & 3 deletions go/vt/topo/consultopo/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,26 @@ import (

"github.com/hashicorp/consul/api"

"vitess.io/vitess/go/vt/vterrors"

"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/vterrors"
)

var (
consulConfig = api.DefaultConfig()
consulAuthClientStaticFile = flag.String("consul_auth_static_file", "", "JSON File to read the topos/tokens from.")
// serfHealth is the default check from consul
consulLockSessionChecks = flag.String("topo_consul_lock_session_checks", "serfHealth", "List of checks for consul session.")
consulLockSessionTTL = flag.String("topo_consul_lock_session_ttl", "", "TTL for consul session.")
consulLockDelay = flag.Duration("topo_consul_lock_delay", 15*time.Second, "LockDelay for consul session.")
)

func init() {
flag.IntVar(&consulConfig.Transport.MaxConnsPerHost, "topo_consul_max_conns_per_host", consulConfig.Transport.MaxConnsPerHost, "Maximum number of consul connections per host.")
flag.IntVar(&consulConfig.Transport.MaxIdleConns, "topo_consul_max_idle_conns", consulConfig.Transport.MaxIdleConns, "Maximum number of idle consul connections.")
flag.DurationVar(&consulConfig.Transport.IdleConnTimeout, "topo_consul_idle_conn_timeout", consulConfig.Transport.IdleConnTimeout, "Maximum amount of time to pool idle connections.")
}

// ClientAuthCred credential to use for consul clusters
type ClientAuthCred struct {
// ACLToken when provided, the client will use this token when making requests to the Consul server.
Expand Down Expand Up @@ -120,7 +126,7 @@ func NewServer(cell, serverAddr, root string) (*Server, error) {
if err != nil {
return nil, err
}
cfg := api.DefaultConfig()
cfg := consulConfig
cfg.Address = serverAddr
if creds != nil {
if creds[cell] != nil {
Expand Down