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

28 lines
564 B
Go

package rangesvc
import (
"io"
"github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/pkg/errors"
)
type localRangeWriter struct {
addr *object.Address
rng *object.Range
storage *engine.StorageEngine
}
func (l *localRangeWriter) WriteTo(w io.Writer) (int64, error) {
rngData, err := engine.GetRange(l.storage, l.addr, l.rng)
if err != nil {
return 0, errors.Wrapf(err, "(%T) could not get object from local storage", l)
}
n, err := w.Write(rngData)
return int64(n), err
}