From 58454d6ae0e482b595cb8c8096c48c1256d0ad49 Mon Sep 17 00:00:00 2001 From: a <a@tuxpa.in> Date: Thu, 11 May 2023 22:47:29 -0500 Subject: [PATCH] simplify streamingConn --- codec/inproc/client.go | 4 ++-- conn.go | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/codec/inproc/client.go b/codec/inproc/client.go index e0bb7c3..585c12d 100644 --- a/codec/inproc/client.go +++ b/codec/inproc/client.go @@ -74,7 +74,7 @@ func (c *Client) Do(ctx context.Context, result any, method string, params any) func (c *Client) BatchCall(ctx context.Context, b ...*jrpc.BatchElem) error { buf := new(bytes.Buffer) enc := json.NewEncoder(buf) - reqs := make([]*jrpc.Request, 0) + reqs := make([]*jrpc.Request, 0, len(b)) ids := make([]int, 0, len(b)) for _, v := range b { id := c.p.NextId() @@ -93,6 +93,7 @@ func (c *Client) BatchCall(ctx context.Context, b ...*jrpc.BatchElem) error { for i := range ids { idx := i go func() { + defer wg.Done() ans, err := c.p.Ask(ctx, ids[idx]) if err != nil { b[idx].Error = err @@ -105,7 +106,6 @@ func (c *Client) BatchCall(ctx context.Context, b ...*jrpc.BatchElem) error { return } } - defer wg.Done() }() } wg.Wait() diff --git a/conn.go b/conn.go index 11c7446..3ad298d 100644 --- a/conn.go +++ b/conn.go @@ -11,8 +11,6 @@ type Conn interface { type StreamingConn interface { Conn - - Notify(ctx context.Context, method string, params any) error Handler } -- GitLab