2020-09-22 06:51:47 +00:00
|
|
|
package searchsvc
|
|
|
|
|
|
|
|
import (
|
2023-04-04 10:05:40 +00:00
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
coreclient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object/util"
|
|
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
2023-07-06 12:36:41 +00:00
|
|
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
2023-03-07 13:38:26 +00:00
|
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-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 {
|
2023-08-24 18:55:36 +00:00
|
|
|
writer *uniqueIDWriter
|
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
|
|
|
|
2023-07-06 12:36:41 +00:00
|
|
|
filters objectSDK.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.
|
2023-04-04 10:05:40 +00:00
|
|
|
type RequestForwarder func(context.Context, 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) {
|
2023-08-24 18:55:36 +00:00
|
|
|
p.writer = newUniqueAddressWriter(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.
|
2023-07-06 12:36:41 +00:00
|
|
|
func (p *Prm) WithSearchFilters(fs objectSDK.SearchFilters) {
|
2021-11-01 08:35:33 +00:00
|
|
|
p.filters = fs
|
|
|
|
}
|