From de3ce406e7dbbd5fabd819f751f3256d6fea31c9 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Tue, 3 Jan 2023 09:24:36 -0800 Subject: [PATCH] Use multiplexed connection in NewFromConn() --- api/api.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/api/api.go b/api/api.go index b01f9b8..59d6c73 100644 --- a/api/api.go +++ b/api/api.go @@ -6,7 +6,6 @@ import ( "go.arsenm.dev/itd/internal/rpc" "storj.io/drpc" - "storj.io/drpc/drpcconn" ) const DefaultAddr = "/tmp/itd/socket" @@ -33,13 +32,16 @@ func New(sockPath string) (*Client, error) { }, nil } -func NewFromConn(conn io.ReadWriteCloser) *Client { - dconn := drpcconn.New(conn) +func NewFromConn(conn io.ReadWriteCloser) (*Client, error) { + mconn, err := newMuxConn(conn) + if err != nil { + return nil, err + } return &Client{ - conn: dconn, - client: rpc.NewDRPCITDClient(dconn), - } + conn: mconn, + client: rpc.NewDRPCITDClient(mconn), + }, nil } func (c *Client) FS() *FSClient {