2021-06-21 14:13:08 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
2022-01-13 15:01:50 +00:00
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
|
2024-11-07 14:32:10 +00:00
|
|
|
rawclient "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/client"
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
2021-06-21 14:13:08 +00:00
|
|
|
)
|
|
|
|
|
2023-02-05 15:59:38 +00:00
|
|
|
// Client is an interface of FrostFS storage
|
2021-06-21 14:13:08 +00:00
|
|
|
// node's client.
|
|
|
|
type Client interface {
|
2023-06-29 06:44:11 +00:00
|
|
|
ObjectPutInit(context.Context, client.PrmObjectPutInit) (client.ObjectWriter, error)
|
2023-07-12 14:47:42 +00:00
|
|
|
ObjectPutSingle(context.Context, client.PrmObjectPutSingle) (*client.ResObjectPutSingle, error)
|
2022-02-25 09:20:49 +00:00
|
|
|
ObjectDelete(context.Context, client.PrmObjectDelete) (*client.ResObjectDelete, error)
|
|
|
|
ObjectGetInit(context.Context, client.PrmObjectGet) (*client.ObjectReader, error)
|
|
|
|
ObjectHead(context.Context, client.PrmObjectHead) (*client.ResObjectHead, error)
|
|
|
|
ObjectSearchInit(context.Context, client.PrmObjectSearch) (*client.ObjectListReader, error)
|
|
|
|
ObjectRangeInit(context.Context, client.PrmObjectRange) (*client.ObjectRangeReader, error)
|
|
|
|
ObjectHash(context.Context, client.PrmObjectHash) (*client.ResObjectHash, error)
|
2022-03-11 15:24:11 +00:00
|
|
|
ExecRaw(f func(client *rawclient.Client) error) error
|
|
|
|
Close() error
|
2022-01-13 15:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MultiAddressClient is an interface of the
|
|
|
|
// Client that supports multihost work.
|
|
|
|
type MultiAddressClient interface {
|
|
|
|
Client
|
2021-06-21 14:13:08 +00:00
|
|
|
|
|
|
|
// RawForAddress must return rawclient.Client
|
|
|
|
// for the passed network.Address.
|
2023-04-18 09:04:59 +00:00
|
|
|
RawForAddress(context.Context, network.Address, func(cli *rawclient.Client) error) error
|
2023-02-08 21:15:36 +00:00
|
|
|
|
|
|
|
ReportError(error)
|
2021-06-21 14:13:08 +00:00
|
|
|
}
|
2021-09-28 04:42:31 +00:00
|
|
|
|
2023-02-05 15:59:38 +00:00
|
|
|
// NodeInfo groups information about a FrostFS storage node needed for Client construction.
|
2021-09-28 04:42:31 +00:00
|
|
|
type NodeInfo struct {
|
|
|
|
addrGroup network.AddressGroup
|
2021-09-28 04:49:28 +00:00
|
|
|
|
2022-09-26 12:34:01 +00:00
|
|
|
externalAddrGroup network.AddressGroup
|
|
|
|
|
2021-09-28 04:49:28 +00:00
|
|
|
key []byte
|
2021-09-28 04:42:31 +00:00
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// SetAddressGroup sets a group of network addresses.
|
2021-09-28 04:42:31 +00:00
|
|
|
func (x *NodeInfo) SetAddressGroup(v network.AddressGroup) {
|
|
|
|
x.addrGroup = v
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// AddressGroup returns a group of network addresses.
|
2021-09-28 04:42:31 +00:00
|
|
|
func (x NodeInfo) AddressGroup() network.AddressGroup {
|
|
|
|
return x.addrGroup
|
|
|
|
}
|
2021-09-28 04:49:28 +00:00
|
|
|
|
2022-09-26 12:34:01 +00:00
|
|
|
// SetExternalAddressGroup sets an external group of network addresses.
|
|
|
|
func (x *NodeInfo) SetExternalAddressGroup(v network.AddressGroup) {
|
|
|
|
x.externalAddrGroup = v
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExternalAddressGroup returns a group of network addresses.
|
|
|
|
func (x NodeInfo) ExternalAddressGroup() network.AddressGroup {
|
|
|
|
return x.externalAddrGroup
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// SetPublicKey sets a public key in a binary format.
|
2021-09-28 04:49:28 +00:00
|
|
|
//
|
|
|
|
// Argument must not be mutated.
|
|
|
|
func (x *NodeInfo) SetPublicKey(v []byte) {
|
|
|
|
x.key = v
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// PublicKey returns a public key in a binary format.
|
2021-09-28 04:49:28 +00:00
|
|
|
//
|
|
|
|
// Result must not be mutated.
|
|
|
|
func (x *NodeInfo) PublicKey() []byte {
|
|
|
|
return x.key
|
|
|
|
}
|