set namespace rather than key (#1331)

This commit is contained in:
Asim Aslam
2020-03-11 22:31:24 +00:00
committed by GitHub
parent 7b385bf163
commit f55493993c
5 changed files with 94 additions and 83 deletions

View File

@@ -7,7 +7,7 @@ import (
)
type serviceNameKey struct{}
type keyKey struct{}
type namespaceKey struct{}
type pathKey struct{}
func ServiceName(name string) source.Option {
@@ -19,12 +19,12 @@ func ServiceName(name string) source.Option {
}
}
func Key(key string) source.Option {
func Namespace(namespace string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, keyKey{}, key)
o.Context = context.WithValue(o.Context, namespaceKey{}, namespace)
}
}