move options to dedicated package
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -22,63 +22,3 @@ func NewContext(ctx context.Context, c Store) context.Context {
|
||||
}
|
||||
return context.WithValue(ctx, storeKey{}, c)
|
||||
}
|
||||
|
||||
// SetOption returns a function to setup a context with given value
|
||||
func SetOption(k, v interface{}) Option {
|
||||
return func(o *Options) {
|
||||
if o.Context == nil {
|
||||
o.Context = context.Background()
|
||||
}
|
||||
o.Context = context.WithValue(o.Context, k, v)
|
||||
}
|
||||
}
|
||||
|
||||
// SetReadOption returns a function to setup a context with given value
|
||||
func SetReadOption(k, v interface{}) ReadOption {
|
||||
return func(o *ReadOptions) {
|
||||
if o.Context == nil {
|
||||
o.Context = context.Background()
|
||||
}
|
||||
o.Context = context.WithValue(o.Context, k, v)
|
||||
}
|
||||
}
|
||||
|
||||
// SetWriteOption returns a function to setup a context with given value
|
||||
func SetWriteOption(k, v interface{}) WriteOption {
|
||||
return func(o *WriteOptions) {
|
||||
if o.Context == nil {
|
||||
o.Context = context.Background()
|
||||
}
|
||||
o.Context = context.WithValue(o.Context, k, v)
|
||||
}
|
||||
}
|
||||
|
||||
// SetListOption returns a function to setup a context with given value
|
||||
func SetListOption(k, v interface{}) ListOption {
|
||||
return func(o *ListOptions) {
|
||||
if o.Context == nil {
|
||||
o.Context = context.Background()
|
||||
}
|
||||
o.Context = context.WithValue(o.Context, k, v)
|
||||
}
|
||||
}
|
||||
|
||||
// SetDeleteOption returns a function to setup a context with given value
|
||||
func SetDeleteOption(k, v interface{}) DeleteOption {
|
||||
return func(o *DeleteOptions) {
|
||||
if o.Context == nil {
|
||||
o.Context = context.Background()
|
||||
}
|
||||
o.Context = context.WithValue(o.Context, k, v)
|
||||
}
|
||||
}
|
||||
|
||||
// SetExistsOption returns a function to setup a context with given value
|
||||
func SetExistsOption(k, v interface{}) ExistsOption {
|
||||
return func(o *ExistsOptions) {
|
||||
if o.Context == nil {
|
||||
o.Context = context.Background()
|
||||
}
|
||||
o.Context = context.WithValue(o.Context, k, v)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user