2020-10-21 09:24:02 +00:00
|
|
|
package policer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
|
|
|
|
)
|
|
|
|
|
|
|
|
type jobQueue struct {
|
|
|
|
localStorage *localstore.Storage
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-11-19 12:45:08 +00:00
|
|
|
jobFilter := object.NewSearchFilters()
|
|
|
|
jobFilter.AddPhyFilter()
|
|
|
|
|
2020-10-29 17:16:49 +00:00
|
|
|
// FIXME: add the ability to limit Select result
|
2020-11-19 12:45:08 +00:00
|
|
|
res, err := q.localStorage.Select(jobFilter)
|
2020-10-29 17:16:49 +00:00
|
|
|
if err != nil {
|
2020-10-21 09:24:02 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-10-29 17:16:49 +00:00
|
|
|
if len(res) < limit {
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return res[:limit], nil
|
2020-10-21 09:24:02 +00:00
|
|
|
}
|