[#1460] blobovnicza: Do not use pointers as the results
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
0e4a1beecf
commit
010253a97a
4 changed files with 12 additions and 12 deletions
|
@ -29,7 +29,7 @@ func (p *DeletePrm) SetAddress(addr oid.Address) {
|
|||
// Returns an error of type apistatus.ObjectNotFound if the object to be deleted is not in blobovnicza.
|
||||
//
|
||||
// Should not be called in read-only configuration.
|
||||
func (b *Blobovnicza) Delete(prm DeletePrm) (*DeleteRes, error) {
|
||||
func (b *Blobovnicza) Delete(prm DeletePrm) (DeleteRes, error) {
|
||||
addrKey := addressKey(prm.addr)
|
||||
|
||||
removed := false
|
||||
|
@ -67,8 +67,8 @@ func (b *Blobovnicza) Delete(prm DeletePrm) (*DeleteRes, error) {
|
|||
if err == nil && !removed {
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
|
||||
return nil, errNotFound
|
||||
return DeleteRes{}, errNotFound
|
||||
}
|
||||
|
||||
return nil, err
|
||||
return DeleteRes{}, err
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func (p GetRes) Object() []byte {
|
|||
//
|
||||
// Returns an error of type apistatus.ObjectNotFound if the requested object is not
|
||||
// presented in Blobovnicza.
|
||||
func (b *Blobovnicza) Get(prm GetPrm) (*GetRes, error) {
|
||||
func (b *Blobovnicza) Get(prm GetPrm) (GetRes, error) {
|
||||
var (
|
||||
data []byte
|
||||
addrKey = addressKey(prm.addr)
|
||||
|
@ -58,16 +58,16 @@ func (b *Blobovnicza) Get(prm GetPrm) (*GetRes, error) {
|
|||
return stop, nil
|
||||
})
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
return GetRes{}, err
|
||||
}
|
||||
|
||||
if data == nil {
|
||||
var errNotFound apistatus.ObjectNotFound
|
||||
|
||||
return nil, errNotFound
|
||||
return GetRes{}, errNotFound
|
||||
}
|
||||
|
||||
return &GetRes{
|
||||
return GetRes{
|
||||
obj: data,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ type IterateRes struct {
|
|||
// Returns handler's errors directly. Returns nil after iterating finish.
|
||||
//
|
||||
// Handler should not retain object data. Handler must not be nil.
|
||||
func (b *Blobovnicza) Iterate(prm IteratePrm) (*IterateRes, error) {
|
||||
func (b *Blobovnicza) Iterate(prm IteratePrm) (IterateRes, error) {
|
||||
var elem IterationElement
|
||||
|
||||
if err := b.boltDB.View(func(tx *bbolt.Tx) error {
|
||||
|
@ -140,10 +140,10 @@ func (b *Blobovnicza) Iterate(prm IteratePrm) (*IterateRes, error) {
|
|||
})
|
||||
})
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
return IterateRes{}, err
|
||||
}
|
||||
|
||||
return new(IterateRes), nil
|
||||
return IterateRes{}, nil
|
||||
}
|
||||
|
||||
// IterateObjects is a helper function which iterates over Blobovnicza and passes binary objects to f.
|
||||
|
|
|
@ -47,7 +47,7 @@ func (p *PutPrm) SetMarshaledObject(data []byte) {
|
|||
// Returns ErrFull if blobovnicza is filled.
|
||||
//
|
||||
// Should not be called in read-only configuration.
|
||||
func (b *Blobovnicza) Put(prm PutPrm) (*PutRes, error) {
|
||||
func (b *Blobovnicza) Put(prm PutPrm) (PutRes, error) {
|
||||
sz := uint64(len(prm.objData))
|
||||
bucketName := bucketForSize(sz)
|
||||
key := addressKey(prm.addr)
|
||||
|
@ -76,7 +76,7 @@ func (b *Blobovnicza) Put(prm PutPrm) (*PutRes, error) {
|
|||
b.incSize(sz)
|
||||
}
|
||||
|
||||
return nil, err
|
||||
return PutRes{}, err
|
||||
}
|
||||
|
||||
func addressKey(addr oid.Address) []byte {
|
||||
|
|
Loading…
Reference in a new issue