watch supports path

This commit is contained in:
shu xian
2020-01-20 18:31:18 +08:00
parent 8d6f82707a
commit 94bb0f4c08
5 changed files with 78 additions and 32 deletions

View File

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