From 6444a844953894ba197421044a1debc191fb8a4e Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Tue, 1 Aug 2023 12:46:36 +0200 Subject: [PATCH] `slack-vitess-r12.0.5`: allow conn overrides in consul topo (#108) * `slack-vitess-r12.0.5`: allow conn overrides in consul topo * empty commit to force ci * empty commit again --- go/vt/topo/consultopo/server.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/go/vt/topo/consultopo/server.go b/go/vt/topo/consultopo/server.go index 8ba22bbf6d0..9f8ed9b3ad1 100644 --- a/go/vt/topo/consultopo/server.go +++ b/go/vt/topo/consultopo/server.go @@ -30,13 +30,13 @@ 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.") @@ -44,6 +44,12 @@ var ( 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. @@ -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 {