storage

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: ISC Imports: 23 Imported by: 25

Documentation

Index

Constants

View Source
const (
	DEFAULT_HASHING_ALGORITHM        = hashing.DEFAULT_HASHING_ALGORITHM
	STORAGE_HEADER_SIZE       uint32 = 16
	STORAGE_FOOTER_SIZE       uint32 = 32
)
View Source
const (
	PHASE_HEADER = iota
	PHASE_DATA
	PHASE_FOOTER
)
View Source
const VERSION string = "1.0.0"

Variables

View Source
var ErrInvalidLocation = fmt.Errorf("invalid location")
View Source
var ErrInvalidMagic = fmt.Errorf("invalid magic")
View Source
var ErrInvalidVersion = fmt.Errorf("invalid version")
View Source
var ErrNotReadable = fmt.Errorf("storage is not readable")
View Source
var ErrNotWritable = fmt.Errorf("storage is not writable")

Functions

func Backends

func Backends() []string

func Deserialize

func Deserialize(hasher hash.Hash, resourceType resources.Type, input io.ReadCloser) (versioning.Version, io.ReadCloser, error)

func Register

func Register(name string, flags location.Flags, backend StoreFn) error

func Serialize

func Serialize(hasher hash.Hash, resourceType resources.Type, version versioning.Version, input io.Reader) (io.Reader, error)

func Unregister

func Unregister(name string) error

Types

type Configuration

type Configuration struct {
	Version      versioning.Version `msgpack:"-" json:"version"`
	Timestamp    time.Time          `json:"timestamp"`
	RepositoryID uuid.UUID          `json:"repository_id"`

	Packfile    packfile.Configuration     `json:"packfile"`
	Chunking    chunking.Configuration     `json:"chunking"`
	Hashing     hashing.Configuration      `json:"hashing"`
	Compression *compression.Configuration `json:"compression"`
	Encryption  *encryption.Configuration  `json:"encryption"`
}

func NewConfiguration

func NewConfiguration() *Configuration

func NewConfigurationFromBytes

func NewConfigurationFromBytes(version versioning.Version, data []byte) (*Configuration, error)

func NewConfigurationFromWrappedBytes

func NewConfigurationFromWrappedBytes(data []byte) (*Configuration, error)

func (*Configuration) ToBytes

func (c *Configuration) ToBytes() ([]byte, error)

type Mode

type Mode uint32
const (
	ModeWrite Mode = 1 << 1
	ModeRead  Mode = 1 << 2
)

type Store

type Store interface {
	Create(ctx context.Context, config []byte) error
	Open(ctx context.Context) ([]byte, error)
	Location(ctx context.Context) (string, error)
	Mode(ctx context.Context) (Mode, error)
	Size(ctx context.Context) (int64, error) // this can be costly, call with caution

	GetStates(ctx context.Context) ([]objects.MAC, error)
	PutState(ctx context.Context, mac objects.MAC, rd io.Reader) (int64, error)
	GetState(ctx context.Context, mac objects.MAC) (io.ReadCloser, error)
	DeleteState(ctx context.Context, mac objects.MAC) error

	GetPackfiles(ctx context.Context) ([]objects.MAC, error)
	PutPackfile(ctx context.Context, mac objects.MAC, rd io.Reader) (int64, error)
	GetPackfile(ctx context.Context, mac objects.MAC) (io.ReadCloser, error)
	GetPackfileBlob(ctx context.Context, mac objects.MAC, offset uint64, length uint32) (io.ReadCloser, error)
	DeletePackfile(ctx context.Context, mac objects.MAC) error

	GetLocks(ctx context.Context) ([]objects.MAC, error)
	PutLock(ctx context.Context, lockID objects.MAC, rd io.Reader) (int64, error)
	GetLock(ctx context.Context, lockID objects.MAC) (io.ReadCloser, error)
	DeleteLock(ctx context.Context, lockID objects.MAC) error

	Close(ctx context.Context) error
}

func Create

func Create(ctx *kcontext.KContext, storeConfig map[string]string, configuration []byte) (Store, error)

func New

func New(ctx *kcontext.KContext, storeConfig map[string]string) (Store, error)

func Open

func Open(ctx *kcontext.KContext, storeConfig map[string]string) (Store, []byte, error)

type StoreFn

type StoreFn func(context.Context, string, map[string]string) (Store, error)

Jump to

Keyboard shortcuts

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