[#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 <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-05-31 09:22:10 +03:00 committed by Leonard Lyubich
parent 22ce8e13cc
commit 89be8d3f5a
2 changed files with 14 additions and 0 deletions

View file

@ -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 {

View file

@ -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()
}