2020-12-26 15:32:45 +00:00
|
|
|
package mucp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-01-20 21:01:10 +00:00
|
|
|
"github.com/asim/go-micro/v3/config/source"
|
2020-12-26 15:32:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type serviceNameKey struct{}
|
|
|
|
type pathKey struct{}
|
|
|
|
|
|
|
|
func WithServiceName(a string) source.Option {
|
|
|
|
return func(o *source.Options) {
|
|
|
|
if o.Context == nil {
|
|
|
|
o.Context = context.Background()
|
|
|
|
}
|
|
|
|
o.Context = context.WithValue(o.Context, serviceNameKey{}, a)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithPath sets the key prefix to use
|
|
|
|
func WithPath(p string) source.Option {
|
|
|
|
return func(o *source.Options) {
|
|
|
|
if o.Context == nil {
|
|
|
|
o.Context = context.Background()
|
|
|
|
}
|
|
|
|
o.Context = context.WithValue(o.Context, pathKey{}, p)
|
|
|
|
}
|
|
|
|
}
|