mirror of
https://github.com/go-micro/go-micro.git
synced 2025-10-06 21:46:55 +02:00
fix consul context key mismatch (#2801)
This commit is contained in:
@@ -82,18 +82,18 @@ func configure(c *consulRegistry, opts ...registry.Option) {
|
|||||||
|
|
||||||
if c.opts.Context != nil {
|
if c.opts.Context != nil {
|
||||||
// Use the consul config passed in the options, if available
|
// Use the consul config passed in the options, if available
|
||||||
if co, ok := c.opts.Context.Value("consul_config").(*consul.Config); ok {
|
if co, ok := c.opts.Context.Value(consulConfigKey).(*consul.Config); ok {
|
||||||
config = co
|
config = co
|
||||||
}
|
}
|
||||||
if cn, ok := c.opts.Context.Value("consul_connect").(bool); ok {
|
if cn, ok := c.opts.Context.Value(consulConnectKey).(bool); ok {
|
||||||
c.connect = cn
|
c.connect = cn
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the consul query options passed in the options, if available
|
// Use the consul query options passed in the options, if available
|
||||||
if qo, ok := c.opts.Context.Value("consul_query_options").(*consul.QueryOptions); ok && qo != nil {
|
if qo, ok := c.opts.Context.Value(consulQueryOptionsKey).(*consul.QueryOptions); ok && qo != nil {
|
||||||
c.queryOptions = qo
|
c.queryOptions = qo
|
||||||
}
|
}
|
||||||
if as, ok := c.opts.Context.Value("consul_allow_stale").(bool); ok {
|
if as, ok := c.opts.Context.Value(consulAllowStaleKey).(bool); ok {
|
||||||
c.queryOptions.AllowStale = as
|
c.queryOptions.AllowStale = as
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,12 +182,12 @@ func (c *consulRegistry) Register(s *registry.Service, opts ...registry.Register
|
|||||||
}
|
}
|
||||||
|
|
||||||
if c.opts.Context != nil {
|
if c.opts.Context != nil {
|
||||||
if tcpCheckInterval, ok := c.opts.Context.Value("consul_tcp_check").(time.Duration); ok {
|
if tcpCheckInterval, ok := c.opts.Context.Value(consulTCPCheckKey).(time.Duration); ok {
|
||||||
regTCPCheck = true
|
regTCPCheck = true
|
||||||
regInterval = tcpCheckInterval
|
regInterval = tcpCheckInterval
|
||||||
}
|
}
|
||||||
var ok bool
|
var ok bool
|
||||||
if httpCheckConfig, ok = c.opts.Context.Value("consul_http_check_config").(consul.AgentServiceCheck); ok {
|
if httpCheckConfig, ok = c.opts.Context.Value(consulHTTPCheckConfigKey).(consul.AgentServiceCheck); ok {
|
||||||
regHTTPCheck = true
|
regHTTPCheck = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user