Skip to content

Commit

Permalink
slack-vitess-r12.0.5: allow conn overrides in consul topo
Browse files Browse the repository at this point in the history
  • Loading branch information
timvaillancourt committed Jul 27, 2023
1 parent 87cb1d3 commit bbc40d4
Showing 1 changed file with 9 additions and 3 deletions.
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

0 comments on commit bbc40d4

Please sign in to comment.