diff --git a/main.go b/main.go index 887425d..3974b88 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,7 @@ func main() { v = settings() l = newLogger(v) g = newGracefulContext(l) + d = v.GetDuration("rebalance_timer") ) if v.GetBool("verbose") { @@ -53,7 +54,7 @@ func main() { timeout: v.GetDuration("request_timeout"), } - go checkConnection(g, r.pool) + go checkConnection(g, d, r.pool) e := echo.New() e.Debug = false @@ -91,8 +92,7 @@ func main() { l.Info("stopping server", zap.Error(e.Shutdown(ctx))) } -func checkConnection(ctx context.Context, p *Pool) { - dur := time.Second * 15 +func checkConnection(ctx context.Context, dur time.Duration, p *Pool) { tick := time.NewTimer(dur) loop: diff --git a/settings.go b/settings.go index 10243da..f21bfd9 100644 --- a/settings.go +++ b/settings.go @@ -28,6 +28,7 @@ const ( defaultTTL = minimumTTLInMinutes * time.Minute + defaultRebalanceTimer = 15 * time.Second defaultRequestTimeout = 15 * time.Second defaultConnectTimeout = 30 * time.Second @@ -86,6 +87,8 @@ func settings() *viper.Viper { flags.Bool("verbose", false, "debug gRPC connections") flags.Duration("request_timeout", defaultRequestTimeout, "gRPC request timeout") flags.Duration("connect_timeout", defaultConnectTimeout, "gRPC connect timeout") + flags.Duration("rebalance_timer", defaultRebalanceTimer, "gRPC connection rebalance timer") + ttl := flags.DurationP("conn_ttl", "t", defaultTTL, "gRPC connection time to live") flags.String("listen_address", "0.0.0.0:8082", "HTTP Gateway listen address")