allocationstore

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2026 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocationStore

type AllocationStore interface {
	// Get retrieves an allocation for a blob (digest) in a space (DID). It
	// returns [github.com/storacha/piri/pkg/store.ErrNotFound] if the allocation
	// does not exist.
	Get(context.Context, multihash.Multihash, did.DID) (allocation.Allocation, error)
	// GetAny retrieves any allocation for a blob (digest), regardless of space.
	// Returns [github.com/storacha/piri/pkg/store.ErrNotFound] if no allocation exists.
	GetAny(context.Context, multihash.Multihash) (allocation.Allocation, error)
	// GetAnyNonExpired retrieves any allocation for a blob that has not expired.
	// The now parameter should be the current unix timestamp in seconds.
	// Returns [github.com/storacha/piri/pkg/store.ErrNotFound] if no non-expired allocation exists.
	GetAnyNonExpired(ctx context.Context, digest multihash.Multihash, now uint64) (allocation.Allocation, error)
	// Exists checks if any allocation exists for a blob (digest).
	Exists(context.Context, multihash.Multihash) (bool, error)
	// Put adds or replaces allocation data in the store.
	Put(context.Context, allocation.Allocation) error
}

AllocationStore tracks the items that have been, or will soon be stored on the storage node.

type DatastoreKeyEncoder added in v0.2.3

type DatastoreKeyEncoder struct{}

DatastoreKeyEncoder encodes keys for LevelDB/datastore backends (no suffix).

func (DatastoreKeyEncoder) EncodeKey added in v0.2.3

func (DatastoreKeyEncoder) EncodeKey(digest multihash.Multihash, space did.DID) string

func (DatastoreKeyEncoder) EncodeKeyPrefix added in v0.2.3

func (DatastoreKeyEncoder) EncodeKeyPrefix(digest multihash.Multihash) string

type KeyEncoder added in v0.2.3

type KeyEncoder interface {
	EncodeKey(digest multihash.Multihash, space did.DID) string
	EncodeKeyPrefix(digest multihash.Multihash) string
}

KeyEncoder defines how to encode keys for a specific backend.

type S3KeyEncoder added in v0.2.3

type S3KeyEncoder struct{}

S3KeyEncoder encodes keys for S3/MinIO backends (keys end with .cbor).

func (S3KeyEncoder) EncodeKey added in v0.2.3

func (S3KeyEncoder) EncodeKey(digest multihash.Multihash, space did.DID) string

func (S3KeyEncoder) EncodeKeyPrefix added in v0.2.3

func (S3KeyEncoder) EncodeKeyPrefix(digest multihash.Multihash) string

type Store added in v0.2.3

type Store struct {
	// contains filtered or unexported fields
}

Store implements AllocationStore backed by any ListableStore.

func New added in v0.2.3

func New(backend objectstore.ListableStore, encoder KeyEncoder) *Store

New creates an AllocationStore with the given backend and key encoder.

func NewDatastoreStore added in v0.2.3

func NewDatastoreStore(ds datastore.Datastore) *Store

NewDatastoreStore creates an AllocationStore for LevelDB/datastore backends. Allocations are stored with keys formatted as "{digest}/{space}".

func NewS3Store added in v0.2.3

func NewS3Store(backend *minio.Store) *Store

NewS3Store creates an AllocationStore for S3/MinIO backends. Allocations are stored with keys formatted as "allocations/{digest}/{space}.cbor".

func (*Store) Exists added in v0.2.3

func (s *Store) Exists(ctx context.Context, digest multihash.Multihash) (bool, error)

func (*Store) Get added in v0.2.3

func (s *Store) Get(ctx context.Context, digest multihash.Multihash, space did.DID) (allocation.Allocation, error)

func (*Store) GetAny added in v0.2.3

func (s *Store) GetAny(ctx context.Context, digest multihash.Multihash) (allocation.Allocation, error)

func (*Store) GetAnyNonExpired added in v0.2.3

func (s *Store) GetAnyNonExpired(ctx context.Context, digest multihash.Multihash, now uint64) (allocation.Allocation, error)

func (*Store) Put added in v0.2.3

func (s *Store) Put(ctx context.Context, alloc allocation.Allocation) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL