Skip to content

Commit

Permalink
peapod: deprecate Peapod
Browse files Browse the repository at this point in the history
Refs #2924.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
  • Loading branch information
End-rey committed Nov 13, 2024
1 parent c88bc8b commit 627f16e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkg/local_object_storage/blobstor/peapod/peapod.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type batch struct {
// Peapod provides storage for relatively small NeoFS binary object (peas).
// Peapod is a single low-level key/value database optimized to work with big
// number of stored units.
//
// Deprecated: Use fstree.FSTree instead.
type Peapod struct {
path string
perm fs.FileMode
Expand Down Expand Up @@ -74,6 +76,8 @@ var errMissingRootBucket = errors.New("missing root bucket")
// - initialize internal database structure (Init method). May be skipped for read-only usage
//
// Any other usage is unsafe and may lead to panic.
//
// Deprecated: Use fstree.New instead.
func New(path string, perm fs.FileMode, flushInterval time.Duration) *Peapod {
if flushInterval <= 0 {
panic(fmt.Sprintf("non-positive flush interval %v", flushInterval))
Expand Down Expand Up @@ -193,6 +197,8 @@ func decodeKeyForObject(addr *oid.Address, key []byte) error {
}

// Open opens underlying database in the specified mode.
//
// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) Open(readOnly bool) error {
err := util.MkdirAllX(filepath.Dir(x.path), x.perm)
if err != nil {
Expand All @@ -215,6 +221,8 @@ func (x *Peapod) Open(readOnly bool) error {
// Init initializes internal structure of the underlying database and runs
// flushing routine. The routine writes data batches into disk once per time
// interval configured in New.
//
// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) Init() error {
if x.readOnly {
err := x.bolt.View(func(tx *bbolt.Tx) error {
Expand Down Expand Up @@ -248,6 +256,8 @@ func (x *Peapod) Init() error {
}

// Close syncs data and closes the database.
//
// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) Close() error {
if !x.readOnly && x.chClose != nil {
close(x.chClose)
Expand All @@ -258,26 +268,34 @@ func (x *Peapod) Close() error {
}

// Type is peapod storage type used in logs and configuration.
//
// Deprecated: Use fstree.Type instead.
const Type = "peapod"

// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) Type() string {
return Type
}

// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) Path() string {
return x.path
}

// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) SetCompressor(cc *compression.Config) {
x.compress = cc
}

// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) SetReportErrorFunc(func(string, error)) {
// no-op like FSTree
}

// Get reads data from the underlying database by the given object address.
// Returns apistatus.ErrObjectNotFound if object is missing in the Peapod.
//
// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) Get(prm common.GetPrm) (common.GetRes, error) {
var data []byte

Expand Down Expand Up @@ -320,6 +338,8 @@ func (x *Peapod) Get(prm common.GetPrm) (common.GetRes, error) {
// GetBytes reads object from the Peapod by address into memory buffer in a
// canonical NeoFS binary format. Returns [apistatus.ObjectNotFound] if object
// is missing.
//
// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) GetBytes(addr oid.Address) ([]byte, error) {
var b []byte

Expand Down Expand Up @@ -359,6 +379,8 @@ func (x *Peapod) GetBytes(addr oid.Address) ([]byte, error) {
}

// GetRange works like Get but reads specific payload range.
//
// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) GetRange(prm common.GetRangePrm) (common.GetRangeRes, error) {
// copy-paste from FSTree
res, err := x.Get(common.GetPrm{Address: prm.Address})
Expand All @@ -381,6 +403,8 @@ func (x *Peapod) GetRange(prm common.GetRangePrm) (common.GetRangeRes, error) {

// Exists checks presence of the object in the underlying database by the given
// address.
//
// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) Exists(prm common.ExistsPrm) (common.ExistsRes, error) {
var res common.ExistsRes

Expand Down Expand Up @@ -409,6 +433,8 @@ var storageID = []byte("peapod")
// returns its error (in this case data may be saved).
//
// Put returns common.ErrReadOnly if Peadpod is read-only.
//
// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) Put(prm common.PutPrm) (common.PutRes, error) {
if !prm.DontCompress {
prm.RawData = x.compress.Compress(prm.RawData)
Expand All @@ -429,6 +455,8 @@ func (x *Peapod) Put(prm common.PutPrm) (common.PutRes, error) {
// missing.
//
// Put returns common.ErrReadOnly if Peadpod is read-only.
//
// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) Delete(prm common.DeletePrm) (common.DeleteRes, error) {
// Track https://github.com/nspcc-dev/neofs-node/issues/2480
err := x.batch(context.TODO(), func(bktRoot *bbolt.Bucket) error {
Expand Down Expand Up @@ -485,6 +513,8 @@ func (x *Peapod) batch(ctx context.Context, fBktRoot func(bktRoot *bbolt.Bucket)
// passes them into LazyHandler or Handler. Break on f's false return.
//
// Use IterateAddresses to iterate over keys only.
//
// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) Iterate(prm common.IteratePrm) (common.IterateRes, error) {
var addr oid.Address

Expand Down Expand Up @@ -544,6 +574,8 @@ func (x *Peapod) Iterate(prm common.IteratePrm) (common.IterateRes, error) {
// IterateAddresses iterates over all objects stored in the underlying database
// and passes their addresses into f. If f returns an error, IterateAddresses
// returns it and breaks.
//
// Deprecated: Use fstree.FSTree instead.
func (x *Peapod) IterateAddresses(f func(addr oid.Address) error) error {
var addr oid.Address

Expand Down

0 comments on commit 627f16e

Please sign in to comment.