2ebb91cb4c
Since raw client initialization is postponed until the first `Raw()` function call, there is no need to init empty( without options) raw client in constructor. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
40 lines
564 B
Go
40 lines
564 B
Go
package client
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"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
|
|
}
|
|
|
|
type clientImpl struct {
|
|
onceInit sync.Once
|
|
|
|
raw *client.Client
|
|
|
|
opts *clientOptions
|
|
}
|
|
|
|
func New(opts ...Option) (Client, error) {
|
|
clientOptions := defaultClientOptions()
|
|
|
|
for i := range opts {
|
|
opts[i](clientOptions)
|
|
}
|
|
|
|
return &clientImpl{
|
|
opts: clientOptions,
|
|
}, nil
|
|
}
|