move rebalance timer to settings

This commit is contained in:
Evgeniy Kulikov 2020-02-27 13:05:37 +03:00
parent c290e4178a
commit 6e917c1982
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2
2 changed files with 6 additions and 3 deletions

View file

@ -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:

View file

@ -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")