mirror of
https://github.com/sourcegraph/jsonrpc2.git
synced 2026-06-20 09:56:52 +02:00
Add CallOpt SetID
SetID allows a caller to control the ID of the request. Previously it was impossible to set the ID of a call.
This commit is contained in:
parent
cffa092597
commit
4fb7cd9079
3 changed files with 91 additions and 3 deletions
10
call_opt.go
10
call_opt.go
|
|
@ -18,3 +18,13 @@ func Meta(meta interface{}) CallOption {
|
|||
return r.SetMeta(meta)
|
||||
})
|
||||
}
|
||||
|
||||
// PickID returns a call option which sets the ID on a request. Care must be
|
||||
// taken to ensure there are no conflicts with any previously picked ID, nor
|
||||
// with the default sequence ID.
|
||||
func PickID(id ID) CallOption {
|
||||
return callOptionFunc(func(r *Request) error {
|
||||
r.ID = id
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue