forked from TrueCloudLab/frostfs-node
[#1101] *: Adopt interface changes of API client from SDK library
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
674f520da7
commit
4f3323f084
14 changed files with 90 additions and 242 deletions
|
@ -3,7 +3,6 @@ package internal
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/accounting"
|
"github.com/nspcc-dev/neofs-sdk-go/accounting"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||||
|
@ -18,12 +17,12 @@ import (
|
||||||
// BalanceOfPrm groups parameters of BalanceOf operation.
|
// BalanceOfPrm groups parameters of BalanceOf operation.
|
||||||
type BalanceOfPrm struct {
|
type BalanceOfPrm struct {
|
||||||
commonPrm
|
commonPrm
|
||||||
ownerIDPrm
|
client.GetBalancePrm
|
||||||
}
|
}
|
||||||
|
|
||||||
// BalanceOfRes groups resulting values of BalanceOf operation.
|
// BalanceOfRes groups resulting values of BalanceOf operation.
|
||||||
type BalanceOfRes struct {
|
type BalanceOfRes struct {
|
||||||
cliRes *client.BalanceOfRes
|
cliRes *client.GetBalanceRes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Balance returns current balance.
|
// Balance returns current balance.
|
||||||
|
@ -35,9 +34,7 @@ func (x BalanceOfRes) Balance() *accounting.Decimal {
|
||||||
//
|
//
|
||||||
// Returns any error prevented the operation from completing correctly in error return.
|
// Returns any error prevented the operation from completing correctly in error return.
|
||||||
func BalanceOf(prm BalanceOfPrm) (res BalanceOfRes, err error) {
|
func BalanceOf(prm BalanceOfPrm) (res BalanceOfRes, err error) {
|
||||||
res.cliRes, err = prm.cli.GetBalance(context.Background(), prm.ownerID,
|
res.cliRes, err = prm.cli.GetBalance(context.Background(), prm.GetBalancePrm)
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -45,7 +42,7 @@ func BalanceOf(prm BalanceOfPrm) (res BalanceOfRes, err error) {
|
||||||
// ListContainersPrm groups parameters of ListContainers operation.
|
// ListContainersPrm groups parameters of ListContainers operation.
|
||||||
type ListContainersPrm struct {
|
type ListContainersPrm struct {
|
||||||
commonPrm
|
commonPrm
|
||||||
ownerIDPrm
|
client.ContainerListPrm
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListContainersRes groups resulting values of ListContainers operation.
|
// ListContainersRes groups resulting values of ListContainers operation.
|
||||||
|
@ -55,16 +52,14 @@ type ListContainersRes struct {
|
||||||
|
|
||||||
// IDList returns list of identifiers of user's containers.
|
// IDList returns list of identifiers of user's containers.
|
||||||
func (x ListContainersRes) IDList() []*cid.ID {
|
func (x ListContainersRes) IDList() []*cid.ID {
|
||||||
return x.cliRes.IDList()
|
return x.cliRes.Containers()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListContainers requests list of NeoFS user's containers.
|
// ListContainers requests list of NeoFS user's containers.
|
||||||
//
|
//
|
||||||
// Returns any error prevented the operation from completing correctly in error return.
|
// Returns any error prevented the operation from completing correctly in error return.
|
||||||
func ListContainers(prm ListContainersPrm) (res ListContainersRes, err error) {
|
func ListContainers(prm ListContainersPrm) (res ListContainersRes, err error) {
|
||||||
res.cliRes, err = prm.cli.ListContainers(context.Background(), prm.ownerID,
|
res.cliRes, err = prm.cli.ListContainers(context.Background(), prm.ContainerListPrm)
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -72,14 +67,7 @@ func ListContainers(prm ListContainersPrm) (res ListContainersRes, err error) {
|
||||||
// PutContainerPrm groups parameters of PutContainer operation.
|
// PutContainerPrm groups parameters of PutContainer operation.
|
||||||
type PutContainerPrm struct {
|
type PutContainerPrm struct {
|
||||||
commonPrm
|
commonPrm
|
||||||
sessionTokenPrm
|
client.ContainerPutPrm
|
||||||
|
|
||||||
cnr *container.Container
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetContainer sets container structure.
|
|
||||||
func (x *PutContainerPrm) SetContainer(cnr *container.Container) {
|
|
||||||
x.cnr = cnr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutContainerRes groups resulting values of PutContainer operation.
|
// PutContainerRes groups resulting values of PutContainer operation.
|
||||||
|
@ -101,10 +89,7 @@ func (x PutContainerRes) ID() *cid.ID {
|
||||||
//
|
//
|
||||||
// Returns any error prevented the operation from completing correctly in error return.
|
// Returns any error prevented the operation from completing correctly in error return.
|
||||||
func PutContainer(prm PutContainerPrm) (res PutContainerRes, err error) {
|
func PutContainer(prm PutContainerPrm) (res PutContainerRes, err error) {
|
||||||
res.cliRes, err = prm.cli.PutContainer(context.Background(), prm.cnr,
|
res.cliRes, err = prm.cli.PutContainer(context.Background(), prm.ContainerPutPrm)
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
client.WithSession(prm.sessionToken),
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -112,7 +97,12 @@ func PutContainer(prm PutContainerPrm) (res PutContainerRes, err error) {
|
||||||
// GetContainerPrm groups parameters of GetContainer operation.
|
// GetContainerPrm groups parameters of GetContainer operation.
|
||||||
type GetContainerPrm struct {
|
type GetContainerPrm struct {
|
||||||
commonPrm
|
commonPrm
|
||||||
containerIDPrm
|
cliPrm client.ContainerGetPrm
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetContainer sets identifier of the container to be read.
|
||||||
|
func (x *GetContainerPrm) SetContainer(id cid.ID) {
|
||||||
|
x.cliPrm.SetContainer(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetContainerRes groups resulting values of GetContainer operation.
|
// GetContainerRes groups resulting values of GetContainer operation.
|
||||||
|
@ -129,9 +119,7 @@ func (x GetContainerRes) Container() *container.Container {
|
||||||
//
|
//
|
||||||
// Returns any error prevented the operation from completing correctly in error return.
|
// Returns any error prevented the operation from completing correctly in error return.
|
||||||
func GetContainer(prm GetContainerPrm) (res GetContainerRes, err error) {
|
func GetContainer(prm GetContainerPrm) (res GetContainerRes, err error) {
|
||||||
res.cliRes, err = prm.cli.GetContainer(context.Background(), prm.cnrID,
|
res.cliRes, err = prm.cli.GetContainer(context.Background(), prm.cliPrm)
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -139,8 +127,7 @@ func GetContainer(prm GetContainerPrm) (res GetContainerRes, err error) {
|
||||||
// DeleteContainerPrm groups parameters of DeleteContainerPrm operation.
|
// DeleteContainerPrm groups parameters of DeleteContainerPrm operation.
|
||||||
type DeleteContainerPrm struct {
|
type DeleteContainerPrm struct {
|
||||||
commonPrm
|
commonPrm
|
||||||
sessionTokenPrm
|
client.ContainerDeletePrm
|
||||||
containerIDPrm
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteContainerRes groups resulting values of DeleteContainer operation.
|
// DeleteContainerRes groups resulting values of DeleteContainer operation.
|
||||||
|
@ -155,10 +142,7 @@ type DeleteContainerRes struct{}
|
||||||
//
|
//
|
||||||
// Returns any error prevented the operation from completing correctly in error return.
|
// Returns any error prevented the operation from completing correctly in error return.
|
||||||
func DeleteContainer(prm DeleteContainerPrm) (res DeleteContainerRes, err error) {
|
func DeleteContainer(prm DeleteContainerPrm) (res DeleteContainerRes, err error) {
|
||||||
_, err = prm.cli.DeleteContainer(context.Background(), prm.cnrID,
|
_, err = prm.cli.DeleteContainer(context.Background(), prm.ContainerDeletePrm)
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
client.WithSession(prm.sessionToken),
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -166,7 +150,7 @@ func DeleteContainer(prm DeleteContainerPrm) (res DeleteContainerRes, err error)
|
||||||
// EACLPrm groups parameters of EACL operation.
|
// EACLPrm groups parameters of EACL operation.
|
||||||
type EACLPrm struct {
|
type EACLPrm struct {
|
||||||
commonPrm
|
commonPrm
|
||||||
containerIDPrm
|
client.EACLPrm
|
||||||
}
|
}
|
||||||
|
|
||||||
// EACLRes groups resulting values of EACL operation.
|
// EACLRes groups resulting values of EACL operation.
|
||||||
|
@ -183,9 +167,7 @@ func (x EACLRes) EACL() *eacl.Table {
|
||||||
//
|
//
|
||||||
// Returns any error prevented the operation from completing correctly in error return.
|
// Returns any error prevented the operation from completing correctly in error return.
|
||||||
func EACL(prm EACLPrm) (res EACLRes, err error) {
|
func EACL(prm EACLPrm) (res EACLRes, err error) {
|
||||||
res.cliRes, err = prm.cli.EACL(context.Background(), prm.cnrID,
|
res.cliRes, err = prm.cli.EACL(context.Background(), prm.EACLPrm)
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -193,14 +175,7 @@ func EACL(prm EACLPrm) (res EACLRes, err error) {
|
||||||
// SetEACLPrm groups parameters of SetEACL operation.
|
// SetEACLPrm groups parameters of SetEACL operation.
|
||||||
type SetEACLPrm struct {
|
type SetEACLPrm struct {
|
||||||
commonPrm
|
commonPrm
|
||||||
sessionTokenPrm
|
client.SetEACLPrm
|
||||||
|
|
||||||
eaclTable *eacl.Table
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetEACLTable sets eACL table structure.
|
|
||||||
func (x *SetEACLPrm) SetEACLTable(table *eacl.Table) {
|
|
||||||
x.eaclTable = table
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetEACLRes groups resulting values of SetEACL operation.
|
// SetEACLRes groups resulting values of SetEACL operation.
|
||||||
|
@ -215,10 +190,7 @@ type SetEACLRes struct{}
|
||||||
//
|
//
|
||||||
// Returns any error prevented the operation from completing correctly in error return.
|
// Returns any error prevented the operation from completing correctly in error return.
|
||||||
func SetEACL(prm SetEACLPrm) (res SetEACLRes, err error) {
|
func SetEACL(prm SetEACLPrm) (res SetEACLRes, err error) {
|
||||||
_, err = prm.cli.SetEACL(context.Background(), prm.eaclTable,
|
_, err = prm.cli.SetEACL(context.Background(), prm.SetEACLPrm)
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
client.WithSession(prm.sessionToken),
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -226,6 +198,7 @@ func SetEACL(prm SetEACLPrm) (res SetEACLRes, err error) {
|
||||||
// NetworkInfoPrm groups parameters of NetworkInfo operation.
|
// NetworkInfoPrm groups parameters of NetworkInfo operation.
|
||||||
type NetworkInfoPrm struct {
|
type NetworkInfoPrm struct {
|
||||||
commonPrm
|
commonPrm
|
||||||
|
client.NetworkInfoPrm
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkInfoRes groups resulting values of NetworkInfo operation.
|
// NetworkInfoRes groups resulting values of NetworkInfo operation.
|
||||||
|
@ -242,9 +215,7 @@ func (x NetworkInfoRes) NetworkInfo() *netmap.NetworkInfo {
|
||||||
//
|
//
|
||||||
// Returns any error prevented the operation from completing correctly in error return.
|
// Returns any error prevented the operation from completing correctly in error return.
|
||||||
func NetworkInfo(prm NetworkInfoPrm) (res NetworkInfoRes, err error) {
|
func NetworkInfo(prm NetworkInfoPrm) (res NetworkInfoRes, err error) {
|
||||||
res.cliRes, err = prm.cli.NetworkInfo(context.Background(),
|
res.cliRes, err = prm.cli.NetworkInfo(context.Background(), prm.NetworkInfoPrm)
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -252,6 +223,7 @@ func NetworkInfo(prm NetworkInfoPrm) (res NetworkInfoRes, err error) {
|
||||||
// NodeInfoPrm groups parameters of NodeInfo operation.
|
// NodeInfoPrm groups parameters of NodeInfo operation.
|
||||||
type NodeInfoPrm struct {
|
type NodeInfoPrm struct {
|
||||||
commonPrm
|
commonPrm
|
||||||
|
client.EndpointInfoPrm
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeInfoRes groups resulting values of NodeInfo operation.
|
// NodeInfoRes groups resulting values of NodeInfo operation.
|
||||||
|
@ -261,21 +233,19 @@ type NodeInfoRes struct {
|
||||||
|
|
||||||
// NodeInfo returns information about the node from netmap.
|
// NodeInfo returns information about the node from netmap.
|
||||||
func (x NodeInfoRes) NodeInfo() *netmap.NodeInfo {
|
func (x NodeInfoRes) NodeInfo() *netmap.NodeInfo {
|
||||||
return x.cliRes.Info().NodeInfo()
|
return x.cliRes.NodeInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
// LatestVersion returns latest NeoFS API version in use.
|
// LatestVersion returns latest NeoFS API version in use.
|
||||||
func (x NodeInfoRes) LatestVersion() *version.Version {
|
func (x NodeInfoRes) LatestVersion() *version.Version {
|
||||||
return x.cliRes.Info().LatestVersion()
|
return x.cliRes.LatestVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeInfo requests information about the remote server from NeoFS netmap.
|
// NodeInfo requests information about the remote server from NeoFS netmap.
|
||||||
//
|
//
|
||||||
// Returns any error prevented the operation from completing correctly in error return.
|
// Returns any error prevented the operation from completing correctly in error return.
|
||||||
func NodeInfo(prm NodeInfoPrm) (res NodeInfoRes, err error) {
|
func NodeInfo(prm NodeInfoPrm) (res NodeInfoRes, err error) {
|
||||||
res.cliRes, err = prm.cli.EndpointInfo(context.Background(),
|
res.cliRes, err = prm.cli.EndpointInfo(context.Background(), prm.EndpointInfoPrm)
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -283,6 +253,7 @@ func NodeInfo(prm NodeInfoPrm) (res NodeInfoRes, err error) {
|
||||||
// CreateSessionPrm groups parameters of CreateSession operation.
|
// CreateSessionPrm groups parameters of CreateSession operation.
|
||||||
type CreateSessionPrm struct {
|
type CreateSessionPrm struct {
|
||||||
commonPrm
|
commonPrm
|
||||||
|
client.CreateSessionPrm
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSessionRes groups resulting values of CreateSession operation.
|
// CreateSessionRes groups resulting values of CreateSession operation.
|
||||||
|
@ -297,16 +268,14 @@ func (x CreateSessionRes) ID() []byte {
|
||||||
|
|
||||||
// SessionKey returns public session key in a binary format.
|
// SessionKey returns public session key in a binary format.
|
||||||
func (x CreateSessionRes) SessionKey() []byte {
|
func (x CreateSessionRes) SessionKey() []byte {
|
||||||
return x.cliRes.SessionKey()
|
return x.cliRes.PublicKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateSession opens new unlimited session with the remote node.
|
// CreateSession opens new unlimited session with the remote node.
|
||||||
//
|
//
|
||||||
// Returns any error prevented the operation from completing correctly in error return.
|
// Returns any error prevented the operation from completing correctly in error return.
|
||||||
func CreateSession(prm CreateSessionPrm) (res CreateSessionRes, err error) {
|
func CreateSession(prm CreateSessionPrm) (res CreateSessionRes, err error) {
|
||||||
res.cliRes, err = prm.cli.CreateSession(context.Background(), math.MaxUint64,
|
res.cliRes, err = prm.cli.CreateSession(context.Background(), prm.CreateSessionPrm)
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -350,7 +319,6 @@ func PutObject(prm PutObjectPrm) (res PutObjectRes, err error) {
|
||||||
putPrm.WithPayloadReader(prm.rdr)
|
putPrm.WithPayloadReader(prm.rdr)
|
||||||
|
|
||||||
res.cliRes, err = prm.cli.PutObject(context.Background(), &putPrm, append(prm.opts,
|
res.cliRes, err = prm.cli.PutObject(context.Background(), &putPrm, append(prm.opts,
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
client.WithSession(prm.sessionToken),
|
client.WithSession(prm.sessionToken),
|
||||||
client.WithBearer(prm.bearerToken),
|
client.WithBearer(prm.bearerToken),
|
||||||
)...)
|
)...)
|
||||||
|
@ -383,7 +351,6 @@ func DeleteObject(prm DeleteObjectPrm) (res DeleteObjectRes, err error) {
|
||||||
delPrm.WithAddress(prm.objAddr)
|
delPrm.WithAddress(prm.objAddr)
|
||||||
|
|
||||||
res.cliRes, err = prm.cli.DeleteObject(context.Background(), &delPrm, append(prm.opts,
|
res.cliRes, err = prm.cli.DeleteObject(context.Background(), &delPrm, append(prm.opts,
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
client.WithSession(prm.sessionToken),
|
client.WithSession(prm.sessionToken),
|
||||||
client.WithBearer(prm.bearerToken),
|
client.WithBearer(prm.bearerToken),
|
||||||
)...)
|
)...)
|
||||||
|
@ -423,7 +390,6 @@ func GetObject(prm GetObjectPrm) (res GetObjectRes, err error) {
|
||||||
getPrm.WithRawFlag(prm.raw)
|
getPrm.WithRawFlag(prm.raw)
|
||||||
|
|
||||||
res.cliRes, err = prm.cli.GetObject(context.Background(), &getPrm, append(prm.opts,
|
res.cliRes, err = prm.cli.GetObject(context.Background(), &getPrm, append(prm.opts,
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
client.WithSession(prm.sessionToken),
|
client.WithSession(prm.sessionToken),
|
||||||
client.WithBearer(prm.bearerToken),
|
client.WithBearer(prm.bearerToken),
|
||||||
)...)
|
)...)
|
||||||
|
@ -472,7 +438,6 @@ func HeadObject(prm HeadObjectPrm) (res HeadObjectRes, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
res.cliRes, err = prm.cli.HeadObject(context.Background(), &cliPrm, append(prm.opts,
|
res.cliRes, err = prm.cli.HeadObject(context.Background(), &cliPrm, append(prm.opts,
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
client.WithSession(prm.sessionToken),
|
client.WithSession(prm.sessionToken),
|
||||||
client.WithBearer(prm.bearerToken),
|
client.WithBearer(prm.bearerToken),
|
||||||
)...)
|
)...)
|
||||||
|
@ -513,7 +478,6 @@ func SearchObjects(prm SearchObjectsPrm) (res SearchObjectsRes, err error) {
|
||||||
cliPrm.WithContainerID(prm.cnrID)
|
cliPrm.WithContainerID(prm.cnrID)
|
||||||
|
|
||||||
res.cliRes, err = prm.cli.SearchObjects(context.Background(), &cliPrm, append(prm.opts,
|
res.cliRes, err = prm.cli.SearchObjects(context.Background(), &cliPrm, append(prm.opts,
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
client.WithSession(prm.sessionToken),
|
client.WithSession(prm.sessionToken),
|
||||||
client.WithBearer(prm.bearerToken),
|
client.WithBearer(prm.bearerToken),
|
||||||
)...)
|
)...)
|
||||||
|
@ -574,7 +538,6 @@ func HashPayloadRanges(prm HashPayloadRangesPrm) (res HashPayloadRangesRes, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res.cliRes, err = prm.cli.HashObjectPayloadRanges(context.Background(), &cliPrm, append(prm.opts,
|
res.cliRes, err = prm.cli.HashObjectPayloadRanges(context.Background(), &cliPrm, append(prm.opts,
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
client.WithSession(prm.sessionToken),
|
client.WithSession(prm.sessionToken),
|
||||||
client.WithBearer(prm.bearerToken),
|
client.WithBearer(prm.bearerToken),
|
||||||
)...)
|
)...)
|
||||||
|
@ -615,7 +578,6 @@ func PayloadRange(prm PayloadRangePrm) (res PayloadRangeRes, err error) {
|
||||||
cliPrm.WithRange(prm.rng)
|
cliPrm.WithRange(prm.rng)
|
||||||
|
|
||||||
_, err = prm.cli.ObjectPayloadRangeData(context.Background(), &cliPrm, append(prm.opts,
|
_, err = prm.cli.ObjectPayloadRangeData(context.Background(), &cliPrm, append(prm.opts,
|
||||||
client.WithKey(prm.privKey),
|
|
||||||
client.WithSession(prm.sessionToken),
|
client.WithSession(prm.sessionToken),
|
||||||
client.WithBearer(prm.bearerToken),
|
client.WithBearer(prm.bearerToken),
|
||||||
)...)
|
)...)
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/ecdsa"
|
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/session"
|
"github.com/nspcc-dev/neofs-sdk-go/session"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/token"
|
"github.com/nspcc-dev/neofs-sdk-go/token"
|
||||||
)
|
)
|
||||||
|
@ -16,8 +14,6 @@ import (
|
||||||
|
|
||||||
type commonPrm struct {
|
type commonPrm struct {
|
||||||
cli *client.Client
|
cli *client.Client
|
||||||
|
|
||||||
privKey *ecdsa.PrivateKey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetClient sets base client for NeoFS API communication.
|
// SetClient sets base client for NeoFS API communication.
|
||||||
|
@ -25,20 +21,6 @@ func (x *commonPrm) SetClient(cli *client.Client) {
|
||||||
x.cli = cli
|
x.cli = cli
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetKey sets private key to sign the request(s).
|
|
||||||
func (x *commonPrm) SetKey(key *ecdsa.PrivateKey) {
|
|
||||||
x.privKey = key
|
|
||||||
}
|
|
||||||
|
|
||||||
type ownerIDPrm struct {
|
|
||||||
ownerID *owner.ID
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetOwner sets identifier of NeoFS user.
|
|
||||||
func (x *ownerIDPrm) SetOwner(id *owner.ID) {
|
|
||||||
x.ownerID = id
|
|
||||||
}
|
|
||||||
|
|
||||||
type containerIDPrm struct {
|
type containerIDPrm struct {
|
||||||
cnrID *cid.ID
|
cnrID *cid.ID
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ var accountingBalanceCmd = &cobra.Command{
|
||||||
var prm internalclient.BalanceOfPrm
|
var prm internalclient.BalanceOfPrm
|
||||||
|
|
||||||
prepareAPIClientWithKey(cmd, key, &prm)
|
prepareAPIClientWithKey(cmd, key, &prm)
|
||||||
prm.SetOwner(oid)
|
prm.SetAccount(*oid)
|
||||||
|
|
||||||
res, err := internalclient.BalanceOf(prm)
|
res, err := internalclient.BalanceOf(prm)
|
||||||
exitOnErr(cmd, errf("rpc error: %w", err))
|
exitOnErr(cmd, errf("rpc error: %w", err))
|
||||||
|
|
|
@ -125,7 +125,7 @@ var listContainersCmd = &cobra.Command{
|
||||||
var prm internalclient.ListContainersPrm
|
var prm internalclient.ListContainersPrm
|
||||||
|
|
||||||
prepareAPIClientWithKey(cmd, key, &prm)
|
prepareAPIClientWithKey(cmd, key, &prm)
|
||||||
prm.SetOwner(oid)
|
prm.SetAccount(*oid)
|
||||||
|
|
||||||
res, err := internalclient.ListContainers(prm)
|
res, err := internalclient.ListContainers(prm)
|
||||||
exitOnErr(cmd, errf("rpc error: %w", err))
|
exitOnErr(cmd, errf("rpc error: %w", err))
|
||||||
|
@ -161,22 +161,35 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
tok, err := getSessionToken(sessionTokenPath)
|
tok, err := getSessionToken(sessionTokenPath)
|
||||||
exitOnErr(cmd, err)
|
exitOnErr(cmd, err)
|
||||||
|
|
||||||
|
key, err := getKey()
|
||||||
|
exitOnErr(cmd, err)
|
||||||
|
|
||||||
|
var idOwner *owner.ID
|
||||||
|
|
||||||
|
if idOwner = tok.OwnerID(); idOwner == nil {
|
||||||
|
idOwner = owner.NewIDFromPublicKey(&key.PublicKey)
|
||||||
|
}
|
||||||
|
|
||||||
cnr := container.New()
|
cnr := container.New()
|
||||||
|
cnr.SetVersion(versionSDK.Current())
|
||||||
cnr.SetPlacementPolicy(placementPolicy)
|
cnr.SetPlacementPolicy(placementPolicy)
|
||||||
cnr.SetBasicACL(basicACL)
|
cnr.SetBasicACL(basicACL)
|
||||||
cnr.SetAttributes(attributes)
|
cnr.SetAttributes(attributes)
|
||||||
cnr.SetNonceUUID(nonce)
|
cnr.SetNonceUUID(nonce)
|
||||||
cnr.SetSessionToken(tok)
|
cnr.SetSessionToken(tok)
|
||||||
cnr.SetOwnerID(tok.OwnerID())
|
cnr.SetOwnerID(idOwner)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
putPrm internalclient.PutContainerPrm
|
putPrm internalclient.PutContainerPrm
|
||||||
getPrm internalclient.GetContainerPrm
|
getPrm internalclient.GetContainerPrm
|
||||||
)
|
)
|
||||||
|
|
||||||
prepareAPIClient(cmd, &putPrm, &getPrm)
|
prepareAPIClientWithKey(cmd, key, &putPrm, &getPrm)
|
||||||
putPrm.SetContainer(cnr)
|
putPrm.SetContainer(*cnr)
|
||||||
putPrm.SetSessionToken(tok)
|
|
||||||
|
if tok != nil {
|
||||||
|
putPrm.SetSessionToken(*tok)
|
||||||
|
}
|
||||||
|
|
||||||
res, err := internalclient.PutContainer(putPrm)
|
res, err := internalclient.PutContainer(putPrm)
|
||||||
exitOnErr(cmd, errf("rpc error: %w", err))
|
exitOnErr(cmd, errf("rpc error: %w", err))
|
||||||
|
@ -188,7 +201,7 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
||||||
if containerAwait {
|
if containerAwait {
|
||||||
cmd.Println("awaiting...")
|
cmd.Println("awaiting...")
|
||||||
|
|
||||||
getPrm.SetContainerID(id)
|
getPrm.SetContainer(*id)
|
||||||
|
|
||||||
for i := 0; i < awaitTimeout; i++ {
|
for i := 0; i < awaitTimeout; i++ {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
@ -223,8 +236,11 @@ Only owner of the container has a permission to remove container.`,
|
||||||
)
|
)
|
||||||
|
|
||||||
prepareAPIClient(cmd, &delPrm, &getPrm)
|
prepareAPIClient(cmd, &delPrm, &getPrm)
|
||||||
delPrm.SetContainerID(id)
|
delPrm.SetContainer(*id)
|
||||||
delPrm.SetSessionToken(tok)
|
|
||||||
|
if tok != nil {
|
||||||
|
delPrm.SetSessionToken(*tok)
|
||||||
|
}
|
||||||
|
|
||||||
_, err = internalclient.DeleteContainer(delPrm)
|
_, err = internalclient.DeleteContainer(delPrm)
|
||||||
exitOnErr(cmd, errf("rpc error: %w", err))
|
exitOnErr(cmd, errf("rpc error: %w", err))
|
||||||
|
@ -234,7 +250,7 @@ Only owner of the container has a permission to remove container.`,
|
||||||
if containerAwait {
|
if containerAwait {
|
||||||
cmd.Println("awaiting...")
|
cmd.Println("awaiting...")
|
||||||
|
|
||||||
getPrm.SetContainerID(id)
|
getPrm.SetContainer(*id)
|
||||||
|
|
||||||
for i := 0; i < awaitTimeout; i++ {
|
for i := 0; i < awaitTimeout; i++ {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
@ -301,7 +317,7 @@ var getContainerInfoCmd = &cobra.Command{
|
||||||
var prm internalclient.GetContainerPrm
|
var prm internalclient.GetContainerPrm
|
||||||
|
|
||||||
prepareAPIClient(cmd, &prm)
|
prepareAPIClient(cmd, &prm)
|
||||||
prm.SetContainerID(id)
|
prm.SetContainer(*id)
|
||||||
|
|
||||||
res, err := internalclient.GetContainer(prm)
|
res, err := internalclient.GetContainer(prm)
|
||||||
exitOnErr(cmd, errf("rpc error: %w", err))
|
exitOnErr(cmd, errf("rpc error: %w", err))
|
||||||
|
@ -342,7 +358,7 @@ var getExtendedACLCmd = &cobra.Command{
|
||||||
var eaclPrm internalclient.EACLPrm
|
var eaclPrm internalclient.EACLPrm
|
||||||
|
|
||||||
prepareAPIClient(cmd, &eaclPrm)
|
prepareAPIClient(cmd, &eaclPrm)
|
||||||
eaclPrm.SetContainerID(id)
|
eaclPrm.SetContainer(*id)
|
||||||
|
|
||||||
res, err := internalclient.EACL(eaclPrm)
|
res, err := internalclient.EACL(eaclPrm)
|
||||||
exitOnErr(cmd, errf("rpc error: %w", err))
|
exitOnErr(cmd, errf("rpc error: %w", err))
|
||||||
|
@ -405,8 +421,11 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
|
||||||
)
|
)
|
||||||
|
|
||||||
prepareAPIClient(cmd, &setEACLPrm, &getEACLPrm)
|
prepareAPIClient(cmd, &setEACLPrm, &getEACLPrm)
|
||||||
setEACLPrm.SetSessionToken(tok)
|
setEACLPrm.SetTable(*eaclTable)
|
||||||
setEACLPrm.SetEACLTable(eaclTable)
|
|
||||||
|
if tok != nil {
|
||||||
|
setEACLPrm.SetSessionToken(*tok)
|
||||||
|
}
|
||||||
|
|
||||||
_, err = internalclient.SetEACL(setEACLPrm)
|
_, err = internalclient.SetEACL(setEACLPrm)
|
||||||
exitOnErr(cmd, errf("rpc error: %w", err))
|
exitOnErr(cmd, errf("rpc error: %w", err))
|
||||||
|
@ -417,7 +436,7 @@ Container ID in EACL table will be substituted with ID from the CLI.`,
|
||||||
|
|
||||||
cmd.Println("awaiting...")
|
cmd.Println("awaiting...")
|
||||||
|
|
||||||
getEACLPrm.SetContainerID(id)
|
getEACLPrm.SetContainer(*id)
|
||||||
|
|
||||||
for i := 0; i < awaitTimeout; i++ {
|
for i := 0; i < awaitTimeout; i++ {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
|
@ -303,7 +303,6 @@ func getEndpointAddress(endpointFlag string) (addr network.Address, err error) {
|
||||||
|
|
||||||
type clientWithKey interface {
|
type clientWithKey interface {
|
||||||
SetClient(*client.Client)
|
SetClient(*client.Client)
|
||||||
SetKey(*ecdsa.PrivateKey)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// reads private key from command args and call prepareAPIClientWithKey with it.
|
// reads private key from command args and call prepareAPIClientWithKey with it.
|
||||||
|
@ -321,7 +320,6 @@ func prepareAPIClientWithKey(cmd *cobra.Command, key *ecdsa.PrivateKey, dst ...c
|
||||||
|
|
||||||
for _, d := range dst {
|
for _, d := range dst {
|
||||||
d.SetClient(cli)
|
d.SetClient(cli)
|
||||||
d.SetKey(key)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,6 +301,7 @@ func initCfg(path string) *cfg {
|
||||||
},
|
},
|
||||||
clientCache: cache.NewSDKClientCache(
|
clientCache: cache.NewSDKClientCache(
|
||||||
apiclient.WithDialTimeout(apiclientconfig.DialTimeout(appCfg)),
|
apiclient.WithDialTimeout(apiclientconfig.DialTimeout(appCfg)),
|
||||||
|
apiclient.WithDefaultPrivateKey(&key.PrivateKey),
|
||||||
),
|
),
|
||||||
persistate: persistate,
|
persistate: persistate,
|
||||||
|
|
||||||
|
|
|
@ -279,20 +279,17 @@ func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadc
|
||||||
|
|
||||||
return &remoteLoadAnnounceWriterProvider{
|
return &remoteLoadAnnounceWriterProvider{
|
||||||
client: c,
|
client: c,
|
||||||
key: r.key,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type remoteLoadAnnounceWriterProvider struct {
|
type remoteLoadAnnounceWriterProvider struct {
|
||||||
client client.Client
|
client client.Client
|
||||||
key *ecdsa.PrivateKey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *remoteLoadAnnounceWriterProvider) InitWriter(ctx context.Context) (loadcontroller.Writer, error) {
|
func (p *remoteLoadAnnounceWriterProvider) InitWriter(ctx context.Context) (loadcontroller.Writer, error) {
|
||||||
return &remoteLoadAnnounceWriter{
|
return &remoteLoadAnnounceWriter{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
client: p.client,
|
client: p.client,
|
||||||
key: p.key,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +297,6 @@ type remoteLoadAnnounceWriter struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
|
||||||
client client.Client
|
client client.Client
|
||||||
key *ecdsa.PrivateKey
|
|
||||||
|
|
||||||
buf []containerSDK.UsedSpaceAnnouncement
|
buf []containerSDK.UsedSpaceAnnouncement
|
||||||
}
|
}
|
||||||
|
@ -312,7 +308,11 @@ func (r *remoteLoadAnnounceWriter) Put(a containerSDK.UsedSpaceAnnouncement) err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remoteLoadAnnounceWriter) Close() error {
|
func (r *remoteLoadAnnounceWriter) Close() error {
|
||||||
_, err := r.client.AnnounceContainerUsedSpace(r.ctx, r.buf, apiClient.WithKey(r.key))
|
var cliPrm apiClient.AnnounceSpacePrm
|
||||||
|
|
||||||
|
cliPrm.SetValues(r.buf)
|
||||||
|
|
||||||
|
_, err := r.client.AnnounceContainerUsedSpace(r.ctx, cliPrm)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
|
||||||
p.SetPrivateKey(rtp.key)
|
p.SetPrivateKey(rtp.key)
|
||||||
p.SetEpoch(rtp.eiCtx.Epoch())
|
p.SetEpoch(rtp.eiCtx.Epoch())
|
||||||
p.SetIteration(rtp.eiCtx.I())
|
p.SetIteration(rtp.eiCtx.I())
|
||||||
p.SetTrust(apiPeerToPeerTrust)
|
p.SetTrust(*apiPeerToPeerTrust)
|
||||||
|
|
||||||
_, err := internalclient.AnnounceIntermediate(p)
|
_, err := internalclient.AnnounceIntermediate(p)
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,8 @@ func (x *AnnounceLocalPrm) SetEpoch(epoch uint64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTrusts sets list of local trust values.
|
// SetTrusts sets list of local trust values.
|
||||||
func (x *AnnounceLocalPrm) SetTrusts(ts []*reputation.Trust) {
|
func (x *AnnounceLocalPrm) SetTrusts(ts []reputation.Trust) {
|
||||||
x.cliPrm.SetTrusts(ts)
|
x.cliPrm.SetValues(ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AnnounceLocalRes groups resulting values of AnnounceLocal operation.
|
// AnnounceLocalRes groups resulting values of AnnounceLocal operation.
|
||||||
|
@ -67,7 +67,7 @@ type AnnounceLocalRes struct{}
|
||||||
func AnnounceLocal(prm AnnounceLocalPrm) (res AnnounceLocalRes, err error) {
|
func AnnounceLocal(prm AnnounceLocalPrm) (res AnnounceLocalRes, err error) {
|
||||||
var cliRes *client.AnnounceLocalTrustRes
|
var cliRes *client.AnnounceLocalTrustRes
|
||||||
|
|
||||||
cliRes, err = prm.cli.AnnounceLocalTrust(prm.ctx, prm.cliPrm, prm.opts...)
|
cliRes, err = prm.cli.AnnounceLocalTrust(prm.ctx, prm.cliPrm)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// pull out an error from status
|
// pull out an error from status
|
||||||
err = apistatus.ErrFromStatus(cliRes.Status())
|
err = apistatus.ErrFromStatus(cliRes.Status())
|
||||||
|
@ -94,8 +94,8 @@ func (x *AnnounceIntermediatePrm) SetIteration(iter uint32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTrust sets current global trust value computed at the iteration.
|
// SetTrust sets current global trust value computed at the iteration.
|
||||||
func (x *AnnounceIntermediatePrm) SetTrust(t *reputation.PeerToPeerTrust) {
|
func (x *AnnounceIntermediatePrm) SetTrust(t reputation.PeerToPeerTrust) {
|
||||||
x.cliPrm.SetTrust(t)
|
x.cliPrm.SetCurrentValue(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AnnounceIntermediateRes groups resulting values of AnnounceIntermediate operation.
|
// AnnounceIntermediateRes groups resulting values of AnnounceIntermediate operation.
|
||||||
|
@ -110,7 +110,7 @@ type AnnounceIntermediateRes struct{}
|
||||||
func AnnounceIntermediate(prm AnnounceIntermediatePrm) (res AnnounceIntermediateRes, err error) {
|
func AnnounceIntermediate(prm AnnounceIntermediatePrm) (res AnnounceIntermediateRes, err error) {
|
||||||
var cliRes *client.AnnounceIntermediateTrustRes
|
var cliRes *client.AnnounceIntermediateTrustRes
|
||||||
|
|
||||||
cliRes, err = prm.cli.AnnounceIntermediateTrust(prm.ctx, prm.cliPrm, prm.opts...)
|
cliRes, err = prm.cli.AnnounceIntermediateTrust(prm.ctx, prm.cliPrm)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// pull out an error from status
|
// pull out an error from status
|
||||||
err = apistatus.ErrFromStatus(cliRes.Status())
|
err = apistatus.ErrFromStatus(cliRes.Status())
|
||||||
|
|
|
@ -67,7 +67,7 @@ type RemoteTrustWriter struct {
|
||||||
client coreclient.Client
|
client coreclient.Client
|
||||||
key *ecdsa.PrivateKey
|
key *ecdsa.PrivateKey
|
||||||
|
|
||||||
buf []*reputationapi.Trust
|
buf []reputationapi.Trust
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
|
func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
|
||||||
|
@ -79,7 +79,7 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
|
||||||
apiTrust.SetValue(t.Value().Float64())
|
apiTrust.SetValue(t.Value().Float64())
|
||||||
apiTrust.SetPeer(apiPeer)
|
apiTrust.SetPeer(apiPeer)
|
||||||
|
|
||||||
rtp.buf = append(rtp.buf, apiTrust)
|
rtp.buf = append(rtp.buf, *apiTrust)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
5
go.mod
5
go.mod
|
@ -13,8 +13,8 @@ require (
|
||||||
github.com/multiformats/go-multiaddr v0.4.0
|
github.com/multiformats/go-multiaddr v0.4.0
|
||||||
github.com/nspcc-dev/hrw v1.0.9
|
github.com/nspcc-dev/hrw v1.0.9
|
||||||
github.com/nspcc-dev/neo-go v0.98.0
|
github.com/nspcc-dev/neo-go v0.98.0
|
||||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220114101721-227a871a04ac
|
github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220127135316-32dd0bb3f9c5
|
||||||
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220121080144-596774ce5bd3
|
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220201140258-9414f42aa349
|
||||||
github.com/nspcc-dev/tzhash v1.5.1
|
github.com/nspcc-dev/tzhash v1.5.1
|
||||||
github.com/panjf2000/ants/v2 v2.4.0
|
github.com/panjf2000/ants/v2 v2.4.0
|
||||||
github.com/paulmach/orb v0.2.2
|
github.com/paulmach/orb v0.2.2
|
||||||
|
@ -33,4 +33,3 @@ require (
|
||||||
|
|
||||||
// Used for debug reasons
|
// Used for debug reasons
|
||||||
// replace github.com/nspcc-dev/neofs-api-go => ../neofs-api-go
|
// replace github.com/nspcc-dev/neofs-api-go => ../neofs-api-go
|
||||||
// replace github.com/nspcc-dev/neofs-sdk-go => ../neofs-sdk-go
|
|
||||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -7,29 +7,12 @@ import (
|
||||||
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
rawclient "github.com/nspcc-dev/neofs-api-go/v2/rpc/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/container"
|
|
||||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/eacl"
|
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client is an interface of NeoFS storage
|
// Client is an interface of NeoFS storage
|
||||||
// node's client.
|
// node's client.
|
||||||
type Client interface {
|
type Client interface {
|
||||||
GetBalance(context.Context, *owner.ID, ...client.CallOption) (*client.BalanceOfRes, error)
|
AnnounceContainerUsedSpace(context.Context, client.AnnounceSpacePrm) (*client.AnnounceSpaceRes, error)
|
||||||
|
|
||||||
PutContainer(context.Context, *container.Container, ...client.CallOption) (*client.ContainerPutRes, error)
|
|
||||||
GetContainer(context.Context, *cid.ID, ...client.CallOption) (*client.ContainerGetRes, error)
|
|
||||||
ListContainers(context.Context, *owner.ID, ...client.CallOption) (*client.ContainerListRes, error)
|
|
||||||
DeleteContainer(context.Context, *cid.ID, ...client.CallOption) (*client.ContainerDeleteRes, error)
|
|
||||||
|
|
||||||
EACL(context.Context, *cid.ID, ...client.CallOption) (*client.EACLRes, error)
|
|
||||||
SetEACL(context.Context, *eacl.Table, ...client.CallOption) (*client.SetEACLRes, error)
|
|
||||||
|
|
||||||
AnnounceContainerUsedSpace(context.Context, []container.UsedSpaceAnnouncement, ...client.CallOption) (*client.AnnounceSpaceRes, error)
|
|
||||||
|
|
||||||
EndpointInfo(context.Context, ...client.CallOption) (*client.EndpointInfoRes, error)
|
|
||||||
NetworkInfo(context.Context, ...client.CallOption) (*client.NetworkInfoRes, error)
|
|
||||||
|
|
||||||
PutObject(context.Context, *client.PutObjectParams, ...client.CallOption) (*client.ObjectPutRes, error)
|
PutObject(context.Context, *client.PutObjectParams, ...client.CallOption) (*client.ObjectPutRes, error)
|
||||||
DeleteObject(context.Context, *client.DeleteObjectParams, ...client.CallOption) (*client.ObjectDeleteRes, error)
|
DeleteObject(context.Context, *client.DeleteObjectParams, ...client.CallOption) (*client.ObjectDeleteRes, error)
|
||||||
|
@ -39,10 +22,8 @@ type Client interface {
|
||||||
ObjectPayloadRangeData(context.Context, *client.RangeDataParams, ...client.CallOption) (*client.ObjectRangeRes, error)
|
ObjectPayloadRangeData(context.Context, *client.RangeDataParams, ...client.CallOption) (*client.ObjectRangeRes, error)
|
||||||
HashObjectPayloadRanges(context.Context, *client.RangeChecksumParams, ...client.CallOption) (*client.ObjectRangeHashRes, error)
|
HashObjectPayloadRanges(context.Context, *client.RangeChecksumParams, ...client.CallOption) (*client.ObjectRangeHashRes, error)
|
||||||
|
|
||||||
AnnounceLocalTrust(context.Context, client.AnnounceLocalTrustPrm, ...client.CallOption) (*client.AnnounceLocalTrustRes, error)
|
AnnounceLocalTrust(context.Context, client.AnnounceLocalTrustPrm) (*client.AnnounceLocalTrustRes, error)
|
||||||
AnnounceIntermediateTrust(context.Context, client.AnnounceIntermediateTrustPrm, ...client.CallOption) (*client.AnnounceIntermediateTrustRes, error)
|
AnnounceIntermediateTrust(context.Context, client.AnnounceIntermediateTrustPrm) (*client.AnnounceIntermediateTrustRes, error)
|
||||||
|
|
||||||
CreateSession(context.Context, uint64, ...client.CallOption) (*client.CreateSessionRes, error)
|
|
||||||
|
|
||||||
Raw() *rawclient.Client
|
Raw() *rawclient.Client
|
||||||
|
|
||||||
|
|
106
pkg/network/cache/multi.go
vendored
106
pkg/network/cache/multi.go
vendored
|
@ -11,10 +11,6 @@ import (
|
||||||
clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client"
|
clientcore "github.com/nspcc-dev/neofs-node/pkg/core/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/container"
|
|
||||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/eacl"
|
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type multiClient struct {
|
type multiClient struct {
|
||||||
|
@ -92,90 +88,9 @@ func (x *multiClient) PutObject(ctx context.Context, p *client.PutObjectParams,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *multiClient) GetBalance(ctx context.Context, id *owner.ID, opts ...client.CallOption) (res *client.BalanceOfRes, err error) {
|
func (x *multiClient) AnnounceContainerUsedSpace(ctx context.Context, prm client.AnnounceSpacePrm) (res *client.AnnounceSpaceRes, err error) {
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
||||||
res, err = c.GetBalance(ctx, id, opts...)
|
res, err = c.AnnounceContainerUsedSpace(ctx, prm)
|
||||||
return err
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *multiClient) PutContainer(ctx context.Context, cnr *container.Container, opts ...client.CallOption) (res *client.ContainerPutRes, err error) {
|
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
|
||||||
res, err = c.PutContainer(ctx, cnr, opts...)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *multiClient) GetContainer(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.ContainerGetRes, err error) {
|
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
|
||||||
res, err = c.GetContainer(ctx, id, opts...)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *multiClient) ListContainers(ctx context.Context, id *owner.ID, opts ...client.CallOption) (res *client.ContainerListRes, err error) {
|
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
|
||||||
res, err = c.ListContainers(ctx, id, opts...)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *multiClient) DeleteContainer(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.ContainerDeleteRes, err error) {
|
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
|
||||||
res, err = c.DeleteContainer(ctx, id, opts...)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *multiClient) EACL(ctx context.Context, id *cid.ID, opts ...client.CallOption) (res *client.EACLRes, err error) {
|
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
|
||||||
res, err = c.EACL(ctx, id, opts...)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *multiClient) SetEACL(ctx context.Context, t *eacl.Table, opts ...client.CallOption) (res *client.SetEACLRes, err error) {
|
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
|
||||||
res, err = c.SetEACL(ctx, t, opts...)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *multiClient) AnnounceContainerUsedSpace(ctx context.Context, as []container.UsedSpaceAnnouncement, opts ...client.CallOption) (res *client.AnnounceSpaceRes, err error) {
|
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
|
||||||
res, err = c.AnnounceContainerUsedSpace(ctx, as, opts...)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *multiClient) EndpointInfo(ctx context.Context, opts ...client.CallOption) (res *client.EndpointInfoRes, err error) {
|
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
|
||||||
res, err = c.EndpointInfo(ctx, opts...)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *multiClient) NetworkInfo(ctx context.Context, opts ...client.CallOption) (res *client.NetworkInfoRes, err error) {
|
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
|
||||||
res, err = c.NetworkInfo(ctx, opts...)
|
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -236,27 +151,18 @@ func (x *multiClient) SearchObjects(ctx context.Context, p *client.SearchObjectP
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *multiClient) CreateSession(ctx context.Context, exp uint64, opts ...client.CallOption) (res *client.CreateSessionRes, err error) {
|
func (x *multiClient) AnnounceLocalTrust(ctx context.Context, prm client.AnnounceLocalTrustPrm) (res *client.AnnounceLocalTrustRes, err error) {
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
||||||
res, err = c.CreateSession(ctx, exp, opts...)
|
res, err = c.AnnounceLocalTrust(ctx, prm)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *multiClient) AnnounceLocalTrust(ctx context.Context, p client.AnnounceLocalTrustPrm, opts ...client.CallOption) (res *client.AnnounceLocalTrustRes, err error) {
|
func (x *multiClient) AnnounceIntermediateTrust(ctx context.Context, prm client.AnnounceIntermediateTrustPrm) (res *client.AnnounceIntermediateTrustRes, err error) {
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
||||||
res, err = c.AnnounceLocalTrust(ctx, p, opts...)
|
res, err = c.AnnounceIntermediateTrust(ctx, prm)
|
||||||
return err
|
|
||||||
})
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *multiClient) AnnounceIntermediateTrust(ctx context.Context, p client.AnnounceIntermediateTrustPrm, opts ...client.CallOption) (res *client.AnnounceIntermediateTrustRes, err error) {
|
|
||||||
err = x.iterateClients(ctx, func(c clientcore.Client) error {
|
|
||||||
res, err = c.AnnounceIntermediateTrust(ctx, p, opts...)
|
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue