Skip to content

Commit

Permalink
peapod: Add description to correctly work with constructed Peapod
Browse files Browse the repository at this point in the history
It's easy to encounter runtime panic due to non-obvious Peapod
interface: some extra methods must be called before data interface usage
(see NeoFS Lens implementation for example).

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Aug 16, 2023
1 parent 6dcaf22 commit 6d802f4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/local_object_storage/blobstor/peapod/peapod.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ var errMissingRootBucket = errors.New("missing root bucket")
// specified permissions.
//
// Specified flush interval MUST be positive (see Init).
//
// Note that resulting Peapod is NOT ready-to-go:
// - configure compression first (SetCompressor method)
// - then open the instance (Open method). Opened Peapod must be finally closed
// - initialize internal database structure (Init method). May be skipped for read-only usage
//
// Any other usage is unsafe and may lead to panic.
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

0 comments on commit 6d802f4

Please sign in to comment.