Skip to content

Commit

Permalink
client: add option helper
Browse files Browse the repository at this point in the history
Signed-off-by: Vasiliy Tolstov <[email protected]>
  • Loading branch information
vtolstov committed Jan 18, 2021
1 parent 2b2bcf4 commit 4783c6d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,13 @@ func SetCallOption(k, v interface{}) CallOption {
o.Context = context.WithValue(o.Context, k, v)
}
}

// 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)
}
}

0 comments on commit 4783c6d

Please sign in to comment.