frostfs-node/pkg/local_object_storage/shard/head.go
Leonard Lyubich 590745204c [#237] metabase: Structure parameters and results of all operations
All parameters and resulting values of all metabase operations are
structured in new types. The most popular scenarios for using operations are
moved to auxiliary functions.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-12-11 17:19:37 +03:00

44 lines
965 B
Go

package shard
import (
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
)
// HeadPrm groups the parameters of Head operation.
type HeadPrm struct {
addr *objectSDK.Address
}
// HeadRes groups resulting values of Head operation.
type HeadRes struct {
obj *object.Object
}
// WithAddress is a Head option to set the address of the requested object.
//
// Option is required.
func (p *HeadPrm) WithAddress(addr *objectSDK.Address) *HeadPrm {
if p != nil {
p.addr = addr
}
return p
}
// Object returns the requested object header.
func (r *HeadRes) Object() *object.Object {
return r.obj
}
// Head reads header of the object from the shard.
//
// Returns any error encountered.
func (s *Shard) Head(prm *HeadPrm) (*HeadRes, error) {
head, err := meta.Get(s.metaBase, prm.addr)
return &HeadRes{
obj: head,
}, err
}