2021-11-09 08:07:49 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2021-11-16 18:15:56 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
2021-11-09 08:07:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|