frostfs-node/pkg/services/policer/queue.go
Leonard Lyubich aa9eb2eaf2 [#186] policer: Use new storage engine for work
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-12-11 17:19:37 +03:00

39 lines
930 B
Go

package policer
import (
"github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
)
type jobQueue struct {
localStorage *engine.StorageEngine
}
var jobFilter object.SearchFilters
func (q *jobQueue) Select(limit int) ([]*object.Address, error) {
// TODO: optimize the logic for selecting objects
// We can prioritize objects for migration, newly arrived objects, etc.
// It is recommended to make changes after updating the metabase
// FIXME: add the ability to limit Select result
res, err := engine.Select(q.localStorage, getJobFilter())
if err != nil {
return nil, err
}
if len(res) < limit {
return res, nil
}
return res[:limit], nil
}
// getJobFilter is a getter for a singleton instance.
func getJobFilter() object.SearchFilters {
if len(jobFilter) == 0 {
jobFilter.AddPhyFilter() // this initiates a list of filters
}
return jobFilter
}