[#231] services/policer: Use engine.List method

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-12-03 15:11:07 +03:00
parent ee1e3931a5
commit e0350efe00

View file

@ -9,15 +9,12 @@ type jobQueue struct {
localStorage *engine.StorageEngine localStorage *engine.StorageEngine
} }
var jobFilter object.SearchFilters
func (q *jobQueue) Select(limit int) ([]*object.Address, error) { func (q *jobQueue) Select(limit int) ([]*object.Address, error) {
// TODO: optimize the logic for selecting objects // TODO: optimize the logic for selecting objects
// We can prioritize objects for migration, newly arrived objects, etc. // We can prioritize objects for migration, newly arrived objects, etc.
// It is recommended to make changes after updating the metabase // It is recommended to make changes after updating the metabase
// FIXME: add the ability to limit Select result res, err := engine.List(q.localStorage, 0) // consider some limit
res, err := engine.Select(q.localStorage, getJobFilter())
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -28,12 +25,3 @@ func (q *jobQueue) Select(limit int) ([]*object.Address, error) {
return res[:limit], 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
}