registry: Use Batch() for all methods #141

Merged
fyrchik merged 1 commit from fyrchik/xk6-frostfs:batch-registry into master 2024-05-30 18:20:43 +00:00

View file

@ -75,7 +75,7 @@ func (o *ObjRegistry) AddObject(cid, oid, s3Bucket, s3Key, payloadHash string) e
} }
func (o *ObjRegistry) SetObjectStatus(id uint64, oldStatus, newStatus string) error { func (o *ObjRegistry) SetObjectStatus(id uint64, oldStatus, newStatus string) error {
return o.boltDB.Update(func(tx *bbolt.Tx) error { return o.boltDB.Batch(func(tx *bbolt.Tx) error {
oldB := tx.Bucket([]byte(oldStatus)) oldB := tx.Bucket([]byte(oldStatus))
if oldB == nil { if oldB == nil {
return fmt.Errorf("bucket doesn't exist: '%s'", oldStatus) return fmt.Errorf("bucket doesn't exist: '%s'", oldStatus)
@ -110,7 +110,7 @@ func (o *ObjRegistry) SetObjectStatus(id uint64, oldStatus, newStatus string) er
} }
func (o *ObjRegistry) DeleteObject(id uint64) error { func (o *ObjRegistry) DeleteObject(id uint64) error {
return o.boltDB.Update(func(tx *bbolt.Tx) error { return o.boltDB.Batch(func(tx *bbolt.Tx) error {
return tx.ForEach(func(_ []byte, b *bbolt.Bucket) error { return tx.ForEach(func(_ []byte, b *bbolt.Bucket) error {
return b.Delete(encodeId(id)) return b.Delete(encodeId(id))
}) })