Use registry.options.Context to set Consul TCP check option
This commit is contained in:
		| @@ -25,9 +25,7 @@ type Options struct { | ||||
| 	HdlrWrappers []HandlerWrapper | ||||
| 	SubWrappers  []SubscriberWrapper | ||||
|  | ||||
| 	RegisterTCPCheck bool | ||||
| 	RegisterTTL      time.Duration | ||||
| 	RegisterInterval time.Duration | ||||
| 	RegisterTTL time.Duration | ||||
|  | ||||
| 	// Debug Handler which can be set by a user | ||||
| 	DebugHandler debug.DebugHandler | ||||
| @@ -166,23 +164,6 @@ func RegisterTTL(t time.Duration) Option { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // | ||||
| // RegisterTCPCheck will tell the service provider to check the service address | ||||
| // and port every `t` interval. It will enabled only if `t` is greater than 0. | ||||
| // This option is for registry using Consul, see `TCP + Interval` more | ||||
| // information [1]. | ||||
| // | ||||
| // [1] https://www.consul.io/docs/agent/checks.html | ||||
| // | ||||
| func RegisterTCPCheck(t time.Duration) Option { | ||||
| 	return func(o *Options) { | ||||
| 		if t > time.Duration(0) { | ||||
| 			o.RegisterTCPCheck = true | ||||
| 			o.RegisterInterval = t | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Wait tells the server to wait for requests to finish before exiting | ||||
| func Wait(b bool) Option { | ||||
| 	return func(o *Options) { | ||||
|   | ||||
| @@ -278,10 +278,7 @@ func (s *rpcServer) Register() error { | ||||
| 	} | ||||
|  | ||||
| 	// create registry options | ||||
| 	rOpts := []registry.RegisterOption{ | ||||
| 		registry.RegisterTTL(config.RegisterTTL), | ||||
| 		registry.RegisterTCPCheck(config.RegisterInterval), | ||||
| 	} | ||||
| 	rOpts := []registry.RegisterOption{registry.RegisterTTL(config.RegisterTTL)} | ||||
|  | ||||
| 	if err := config.Registry.Register(service, rOpts...); err != nil { | ||||
| 		return err | ||||
|   | ||||
		Reference in New Issue
	
	Block a user