forked from TrueCloudLab/frostfs-sdk-go
9dcff95a29
Define base `Status` interface. Provide the functionality to distinguish success and failure returns. Provide functionality to transport statuses over NeoFS API V2 protocol. Support success `OK` and failure `INTERNAL` returns. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
45 lines
757 B
Go
45 lines
757 B
Go
package client
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/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
|
|
}
|