2020-09-22 06:51:47 +00:00
|
|
|
package searchsvc
|
|
|
|
|
|
|
|
import (
|
2021-06-21 14:13:08 +00:00
|
|
|
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
|
2020-09-29 15:05:22 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
|
2021-11-10 07:08:33 +00:00
|
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
2022-03-03 14:19:05 +00:00
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/object"
|
2022-05-31 17:00:41 +00:00
|
|
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
2020-09-22 06:51:47 +00:00
|
|
|
)
|
|
|
|
|
2020-12-10 12:26:40 +00:00
|
|
|
// Prm groups parameters of Get service call.
|
2020-09-22 06:51:47 +00:00
|
|
|
type Prm struct {
|
2020-12-10 12:26:40 +00:00
|
|
|
writer IDListWriter
|
2020-09-22 06:51:47 +00:00
|
|
|
|
2020-12-10 12:26:40 +00:00
|
|
|
common *util.CommonPrm
|
2020-09-22 06:51:47 +00:00
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
cnr cid.ID
|
2021-11-01 08:35:33 +00:00
|
|
|
|
2022-03-03 14:19:05 +00:00
|
|
|
filters object.SearchFilters
|
2021-04-29 08:54:40 +00:00
|
|
|
|
|
|
|
forwarder RequestForwarder
|
2020-12-10 12:26:40 +00:00
|
|
|
}
|
2020-09-22 06:51:47 +00:00
|
|
|
|
2020-12-10 12:26:40 +00:00
|
|
|
// IDListWriter is an interface of target component
|
|
|
|
// to write list of object identifiers.
|
|
|
|
type IDListWriter interface {
|
2022-05-31 17:00:41 +00:00
|
|
|
WriteIDs([]oid.ID) error
|
2020-09-22 06:51:47 +00:00
|
|
|
}
|
|
|
|
|
2021-04-29 08:54:40 +00:00
|
|
|
// RequestForwarder is a callback for forwarding of the
|
|
|
|
// original Search requests.
|
2022-05-31 17:00:41 +00:00
|
|
|
type RequestForwarder func(coreclient.NodeInfo, coreclient.MultiAddressClient) ([]oid.ID, error)
|
2021-04-29 08:54:40 +00:00
|
|
|
|
2020-12-10 12:26:40 +00:00
|
|
|
// SetCommonParameters sets common parameters of the operation.
|
|
|
|
func (p *Prm) SetCommonParameters(common *util.CommonPrm) {
|
|
|
|
p.common = common
|
|
|
|
}
|
2020-09-22 06:51:47 +00:00
|
|
|
|
2020-12-10 12:26:40 +00:00
|
|
|
// SetWriter sets target component to write list of object identifiers.
|
|
|
|
func (p *Prm) SetWriter(w IDListWriter) {
|
|
|
|
p.writer = w
|
2020-09-22 06:51:47 +00:00
|
|
|
}
|
2021-04-29 08:54:40 +00:00
|
|
|
|
|
|
|
// SetRequestForwarder sets callback for forwarding
|
|
|
|
// of the original request.
|
|
|
|
func (p *Prm) SetRequestForwarder(f RequestForwarder) {
|
|
|
|
p.forwarder = f
|
|
|
|
}
|
2021-11-01 08:35:33 +00:00
|
|
|
|
|
|
|
// WithContainerID sets identifier of the container to search the objects.
|
2022-05-31 17:00:41 +00:00
|
|
|
func (p *Prm) WithContainerID(id cid.ID) {
|
|
|
|
p.cnr = id
|
2021-11-01 08:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// WithSearchFilters sets search filters.
|
2022-03-03 14:19:05 +00:00
|
|
|
func (p *Prm) WithSearchFilters(fs object.SearchFilters) {
|
2021-11-01 08:35:33 +00:00
|
|
|
p.filters = fs
|
|
|
|
}
|