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-r14.0.5: allow conn overrides in consul topo #111

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
6 changes: 6 additions & 0 deletions go/flags/endtoend/vtgate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,18 @@ Usage of vtgate:
wait till connected for specified tablet types during Gateway initialization
--tablet_url_template string
format string describing debug tablet url formatting. See the Go code for getTabletDebugURL() how to customize this. (default http://{{.GetTabletHostPort}})
--topo_consul_idle_conn_timeout duration
Maximum amount of time to pool idle connections. (default 1m30s)
--topo_consul_lock_delay duration
LockDelay for consul session. (default 15s)
--topo_consul_lock_session_checks string
List of checks for consul session. (default serfHealth)
--topo_consul_lock_session_ttl string
TTL for consul session.
--topo_consul_max_conns_per_host int
Maximum number of consul connections per host.
--topo_consul_max_idle_conns int
Maximum number of idle consul connections. (default 100)
--topo_consul_watch_poll_duration duration
time of the long poll for watch queries. (default 30s)
--topo_etcd_lease_ttl int
Expand Down
6 changes: 6 additions & 0 deletions go/flags/endtoend/vttablet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -847,12 +847,18 @@ Usage of vttablet:
Comma separated VTTablet types to be considered by the throttler. default: 'replica'. example: 'replica,rdonly'. 'replica' aways implicitly included (default replica)
--throttle_threshold duration
Replication lag threshold for default lag throttling (default 1s)
--topo_consul_idle_conn_timeout duration
Maximum amount of time to pool idle connections. (default 1m30s)
--topo_consul_lock_delay duration
LockDelay for consul session. (default 15s)
--topo_consul_lock_session_checks string
List of checks for consul session. (default serfHealth)
--topo_consul_lock_session_ttl string
TTL for consul session.
--topo_consul_max_conns_per_host int
Maximum number of consul connections per host.
--topo_consul_max_idle_conns int
Maximum number of idle consul connections. (default 100)
--topo_consul_watch_poll_duration duration
time of the long poll for watch queries. (default 30s)
--topo_etcd_lease_ttl int
Expand Down
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
Loading