rename stuff per feedback

This commit is contained in:
magodo 2019-06-25 22:41:31 +08:00
parent 8e4fd16aff
commit a8dbca756c
2 changed files with 5 additions and 5 deletions

View File

@ -75,7 +75,7 @@ func NewSource(opts ...source.Option) source.Source {
config := api.DefaultConfig()
// use the consul config passed in the options if any
if co, ok := options.Context.Value(consulConfigKey{}).(*api.Config); ok {
if co, ok := options.Context.Value(configKey{}).(*api.Config); ok {
config = co
}

View File

@ -12,7 +12,7 @@ type prefixKey struct{}
type stripPrefixKey struct{}
type dcKey struct{}
type tokenKey struct{}
type consulConfigKey struct{}
type configKey struct{}
// WithAddress sets the consul address
func WithAddress(a string) source.Option {
@ -64,12 +64,12 @@ func WithToken(p string) source.Option {
}
}
// WithConsulConfig set consul-specific options
func WithConsulConfig(c *api.Config) source.Option {
// WithConfig set consul-specific options
func WithConfig(c *api.Config) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, consulConfigKey{}, c)
o.Context = context.WithValue(o.Context, configKey{}, c)
}
}