forked from TrueCloudLab/frostfs-sdk-go
[#62] client: move package from neofs-api-go
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
6c55c0fd4b
commit
4855154b35
11 changed files with 2651 additions and 0 deletions
45
client/client.go
Normal file
45
client/client.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/rpc/client"
|
||||
)
|
||||
|
||||
// Client represents NeoFS client.
|
||||
type Client interface {
|
||||
Accounting
|
||||
Container
|
||||
Netmap
|
||||
Object
|
||||
Session
|
||||
Reputation
|
||||
|
||||
// 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 {
|
||||
raw *client.Client
|
||||
|
||||
opts *clientOptions
|
||||
}
|
||||
|
||||
func New(opts ...Option) (Client, error) {
|
||||
clientOptions := defaultClientOptions()
|
||||
|
||||
for i := range opts {
|
||||
opts[i](clientOptions)
|
||||
}
|
||||
|
||||
return &clientImpl{
|
||||
opts: clientOptions,
|
||||
raw: client.New(clientOptions.rawOpts...),
|
||||
}, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue