forked from TrueCloudLab/frostfs-api-go
[#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:
parent
22ce8e13cc
commit
89be8d3f5a
2 changed files with 14 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/rpc/client"
|
"github.com/nspcc-dev/neofs-api-go/rpc/client"
|
||||||
|
@ -17,6 +18,12 @@ type Client interface {
|
||||||
|
|
||||||
// Raw must return underlying raw protobuf client.
|
// Raw must return underlying raw protobuf client.
|
||||||
Raw() *client.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 {
|
type clientImpl struct {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/rpc/client"
|
"github.com/nspcc-dev/neofs-api-go/rpc/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,3 +14,8 @@ func (c *clientImpl) Raw() *client.Client {
|
||||||
|
|
||||||
return c.raw
|
return c.raw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// implements Client.Conn method.
|
||||||
|
func (c *clientImpl) Conn() io.Closer {
|
||||||
|
return c.raw.Conn()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue