micro/config/source/memory/options.go
2019-05-30 23:11:13 +01:00

33 lines
685 B
Go

package memory
import (
"context"
"github.com/micro/go-micro/config/source"
)
type changeSetKey struct{}
// WithChangeSet allows a changeset to be set
func WithChangeSet(cs *source.ChangeSet) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, changeSetKey{}, cs)
}
}
// WithData allows the source data to be set
func WithData(d []byte) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, changeSetKey{}, &source.ChangeSet{
Data: d,
Format: "json",
})
}
}