config: add watch option helper

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-11-18 15:57:14 +03:00
parent fbad257acc
commit b9bbfdf159

View File

@ -52,3 +52,13 @@ func SetLoadOption(k, v interface{}) LoadOption {
o.Context = context.WithValue(o.Context, k, v)
}
}
// SetWatchOption returns a function to setup a context with given value
func SetWatchOption(k, v interface{}) WatchOption {
return func(o *WatchOptions) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, k, v)
}
}