internal/jsonrpc2_v2: move the idle timeout handling out of the server
Change-Id: Ia7dedd84171f4fc4818fb00b154c21b04887391f Reviewed-on: https://go-review.googlesource.com/c/tools/+/305129 Trust: Ian Cottrell <iancottrell@google.com> Run-TryBot: Ian Cottrell <iancottrell@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
cf8963447b
commit
76e263b8c9
1 changed files with 163 additions and 101 deletions
|
|
@ -23,12 +23,9 @@ func TestIdleTimeout(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
listener = jsonrpc2.NewIdleListener(100*time.Millisecond, listener)
|
||||
defer listener.Close()
|
||||
|
||||
server, err := jsonrpc2.Serve(ctx, listener, jsonrpc2.ConnectionOptions{},
|
||||
jsonrpc2.ServeOptions{
|
||||
IdleTimeout: 100 * time.Millisecond,
|
||||
})
|
||||
server, err := jsonrpc2.Serve(ctx, listener, jsonrpc2.ConnectionOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -119,10 +116,9 @@ func TestServe(t *testing.T) {
|
|||
}
|
||||
|
||||
func newFake(ctx context.Context, l jsonrpc2.Listener) (*jsonrpc2.Connection, func(context.Context), error) {
|
||||
l = jsonrpc2.NewIdleListener(100*time.Millisecond, l)
|
||||
server, err := jsonrpc2.Serve(ctx, l, jsonrpc2.ConnectionOptions{
|
||||
Handler: fakeHandler{},
|
||||
}, jsonrpc2.ServeOptions{
|
||||
IdleTimeout: 100 * time.Millisecond,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
|
|
|||
Loading…
Reference in a new issue