2020-08-25 11:51:00 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
2021-03-12 13:07:52 +00:00
|
|
|
"sync"
|
2020-08-25 11:51:00 +00:00
|
|
|
|
2021-03-12 13:07:52 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/rpc/client"
|
2020-08-25 11:51:00 +00:00
|
|
|
)
|
|
|
|
|
2021-03-12 13:07:52 +00:00
|
|
|
// Client represents NeoFS client.
|
|
|
|
type Client interface {
|
|
|
|
Accounting
|
|
|
|
Container
|
|
|
|
Netmap
|
|
|
|
Object
|
|
|
|
Session
|
2021-03-24 08:29:02 +00:00
|
|
|
Reputation
|
2021-03-17 11:16:22 +00:00
|
|
|
|
|
|
|
// Raw must return underlying raw protobuf client.
|
|
|
|
Raw() *client.Client
|
2021-03-12 13:07:52 +00:00
|
|
|
}
|
2020-08-25 11:51:00 +00:00
|
|
|
|
2021-03-12 13:07:52 +00:00
|
|
|
type clientImpl struct {
|
|
|
|
onceInit sync.Once
|
2020-08-25 11:51:00 +00:00
|
|
|
|
2021-03-12 13:07:52 +00:00
|
|
|
raw *client.Client
|
2020-08-25 11:51:00 +00:00
|
|
|
|
2021-03-12 13:07:52 +00:00
|
|
|
opts *clientOptions
|
|
|
|
}
|
2020-08-25 11:51:00 +00:00
|
|
|
|
2021-03-12 13:07:52 +00:00
|
|
|
func New(opts ...Option) (Client, error) {
|
2020-08-25 11:51:00 +00:00
|
|
|
clientOptions := defaultClientOptions()
|
2020-11-16 15:10:51 +00:00
|
|
|
|
2020-08-25 11:51:00 +00:00
|
|
|
for i := range opts {
|
2021-03-12 13:07:52 +00:00
|
|
|
opts[i](clientOptions)
|
2020-08-25 11:51:00 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 15:02:26 +00:00
|
|
|
return &clientImpl{
|
2021-03-12 13:07:52 +00:00
|
|
|
raw: client.New(),
|
2020-08-25 11:51:00 +00:00
|
|
|
opts: clientOptions,
|
|
|
|
}, nil
|
|
|
|
}
|