1
0
Fork 0
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:
Keegan Carruthers-Smith 2017-01-31 11:08:53 +02:00
parent cffa092597
commit 4fb7cd9079
3 changed files with 91 additions and 3 deletions

View file

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