Use registry.options.Context to set Consul TCP check option
This commit is contained in:
@@ -14,6 +14,10 @@ import (
|
||||
hash "github.com/mitchellh/hashstructure"
|
||||
)
|
||||
|
||||
const (
|
||||
ConsulRegisterTCPCheckKey = "consul_register_tcp_check"
|
||||
)
|
||||
|
||||
type consulRegistry struct {
|
||||
Address string
|
||||
Client *consul.Client
|
||||
@@ -138,6 +142,15 @@ func (c *consulRegistry) Register(s *Service, opts ...RegisterOption) error {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
if c.opts.Context != nil {
|
||||
tcpCheckInterval, ok := c.opts.Context.
|
||||
Value(ConsulRegisterTCPCheckKey).(time.Duration)
|
||||
if ok {
|
||||
options.TCPCheck = true
|
||||
options.Interval = tcpCheckInterval
|
||||
}
|
||||
}
|
||||
|
||||
// create hash of service; uint64
|
||||
h, err := hash.Hash(s, nil)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user