storage

package
v0.0.0-...-c6effd4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAddressAlreadyReserved = errors.New("virtual account address already in storage")
	ErrAlreadyInitialized     = errors.New("storage account already initalized")
	ErrInvalidInitialCapacity = errors.New("available capacity must be maximum when initializing storage")
	ErrNoFreeStorage          = errors.New("no available free storage")
	ErrNotFound               = errors.New("no storage accounts found")
)

Functions

func GetMaxCapacity

func GetMaxCapacity(levels uint8) uint64

Types

type Purpose

type Purpose uint8
const (
	PurposeUnknown  Purpose = iota
	PurposeDeletion         // Purely used to "delete" accounts that will never make it back to memory. At capacity, we can throw the entire account away and any DB storage.
)

type Record

type Record struct {
	Id uint64

	Vm string

	Name              string
	Address           string
	Levels            uint8
	AvailableCapacity uint64
	Purpose           Purpose

	CreatedAt time.Time
}

func (*Record) Clone

func (r *Record) Clone() Record

func (*Record) CopyTo

func (r *Record) CopyTo(dst *Record)

func (*Record) Validate

func (r *Record) Validate() error

type Store

type Store interface {
	// Initializes a VM storage account for management
	InitializeStorage(ctx context.Context, record *Record) error

	// FindAnyWithAvailableCapacity finds a VM storage account with minimum available capcity
	FindAnyWithAvailableCapacity(ctx context.Context, vm string, purpose Purpose, minCapacity uint64) (*Record, error)

	// ReserveStorage reserves a piece of storage in a VM for the virtual account address
	ReserveStorage(ctx context.Context, vm string, purpose Purpose, address string) (string, error)
}

Store implements a basic construct for managing compression storage.

Note: A lock outside this implementation is required to resolve any races.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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