registry: [gossip] add ConnectRetry and ConnectTimeout
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -2,6 +2,7 @@ package gossip
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/memberlist"
|
||||
"github.com/micro/go-micro/registry"
|
||||
@@ -44,3 +45,18 @@ type contextContext struct{}
|
||||
func Context(ctx context.Context) registry.Option {
|
||||
return setRegistryOption(contextContext{}, ctx)
|
||||
}
|
||||
|
||||
type connectTimeout struct{}
|
||||
|
||||
// ConnectTimeout specify registry connect timeout use -1 to specify infinite
|
||||
func ConnectTimeout(td time.Duration) registry.Option {
|
||||
return setRegistryOption(connectTimeout{}, td)
|
||||
}
|
||||
|
||||
type connectRetry struct{}
|
||||
|
||||
// ConnectRetry enable reconnect to registry then connection closed,
|
||||
// use with ConnectTimeout to specify how long retry
|
||||
func ConnectRetry(v bool) registry.Option {
|
||||
return setRegistryOption(connectRetry{}, v)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user