internal/jsonrpc2_v2: add Func convenience wrappers for the Binder and Preempter interfaces
Change-Id: Ib21dabb908c13d9bbf50f053a342a8644d3ee68b Reviewed-on: https://go-review.googlesource.com/c/tools/+/388596 Run-TryBot: Bryan Mills <bcmills@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
8db5747d28
commit
5d6e2930bf
1 changed files with 21 additions and 0 deletions
|
|
@ -28,6 +28,15 @@ type Binder interface {
|
|||
Bind(context.Context, *Connection) (ConnectionOptions, error)
|
||||
}
|
||||
|
||||
// A BinderFunc implements the Binder interface for a standalone Bind function.
|
||||
type BinderFunc func(context.Context, *Connection) (ConnectionOptions, error)
|
||||
|
||||
func (f BinderFunc) Bind(ctx context.Context, c *Connection) (ConnectionOptions, error) {
|
||||
return f(ctx, c)
|
||||
}
|
||||
|
||||
var _ Binder = BinderFunc(nil)
|
||||
|
||||
// ConnectionOptions holds the options for new connections.
|
||||
type ConnectionOptions struct {
|
||||
// Framer allows control over the message framing and encoding.
|
||||
|
|
|
|||
Loading…
Reference in a new issue