From 89be8d3f5ada752f2b728925b62f82bc5a5a0bd4 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 31 May 2021 09:22:10 +0300 Subject: [PATCH] [#196] pkg/client: Extend Client interface with Conn method Add `Conn` method to `Client` interface which must return the underlying connection. Implement new method on the core structure. `Conn` can be used to control the connection (e.g. for closing). Signed-off-by: Leonard Lyubich --- pkg/client/client.go | 7 +++++++ pkg/client/raw.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/pkg/client/client.go b/pkg/client/client.go index 8fe4d1e..4ffbd30 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -1,6 +1,7 @@ package client import ( + "io" "sync" "github.com/nspcc-dev/neofs-api-go/rpc/client" @@ -17,6 +18,12 @@ type Client interface { // Raw must return underlying raw protobuf client. Raw() *client.Client + + // Conn must return underlying connection. + // + // Must return a non-nil result after the first RPC call + // completed without a connection error. + Conn() io.Closer } type clientImpl struct { diff --git a/pkg/client/raw.go b/pkg/client/raw.go index a8fce33..aebe143 100644 --- a/pkg/client/raw.go +++ b/pkg/client/raw.go @@ -1,6 +1,8 @@ package client import ( + "io" + "github.com/nspcc-dev/neofs-api-go/rpc/client" ) @@ -12,3 +14,8 @@ func (c *clientImpl) Raw() *client.Client { return c.raw } + +// implements Client.Conn method. +func (c *clientImpl) Conn() io.Closer { + return c.raw.Conn() +}