forked from TrueCloudLab/frostfs-node
3805b0f638
There is a need to generalize single-address client to group-address client. To do this, we can re-implement `Client` interface from NeoFS API Go library and still use it in the application code. There is a problem with method `Raw` which must return single-address raw client. So as not to make changes to API library we need to overload Client interface in order to support `Raw` method in group-address client implementation. Define `Client` interface in new `pkg/core/client` package. Completely inherit API `Client` interface. Add `RawForAddress` method to build raw client for the single node address. Adopt the application code that used Raw method to work with new `Client`. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package searchsvc
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
|
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
|
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
|
|
"github.com/nspcc-dev/neofs-node/pkg/network"
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
|
)
|
|
|
|
// Prm groups parameters of Get service call.
|
|
type Prm struct {
|
|
writer IDListWriter
|
|
|
|
common *util.CommonPrm
|
|
|
|
client.SearchObjectParams
|
|
|
|
forwarder RequestForwarder
|
|
}
|
|
|
|
// IDListWriter is an interface of target component
|
|
// to write list of object identifiers.
|
|
type IDListWriter interface {
|
|
WriteIDs([]*objectSDK.ID) error
|
|
}
|
|
|
|
// RequestForwarder is a callback for forwarding of the
|
|
// original Search requests.
|
|
type RequestForwarder func(network.Address, coreclient.Client) ([]*objectSDK.ID, error)
|
|
|
|
// SetCommonParameters sets common parameters of the operation.
|
|
func (p *Prm) SetCommonParameters(common *util.CommonPrm) {
|
|
p.common = common
|
|
}
|
|
|
|
// SetWriter sets target component to write list of object identifiers.
|
|
func (p *Prm) SetWriter(w IDListWriter) {
|
|
p.writer = w
|
|
}
|
|
|
|
// SetRequestForwarder sets callback for forwarding
|
|
// of the original request.
|
|
func (p *Prm) SetRequestForwarder(f RequestForwarder) {
|
|
p.forwarder = f
|
|
}
|