storage

package
v0.0.0-...-ec38784 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListFSEntities

func ListFSEntities[T proto.Message](f *FileStorage, validate func(entry T) bool) (entities []T, err error)

func LoadFSArtifact

func LoadFSArtifact[T proto.Message](f *FileStorage, id string, name string) (out T, err error)

func NewRandomId

func NewRandomId(numChars ...int) (string, error)

NewRandomId generates a new unique random ID of specified length (default 8 chars)

Types

type FileStorage

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

Generic file storage we can use for various kinds of entities These all share a few things in common: 1. A file storage dir 2. Each dir in this storage dir represents a unique entity by id 3. Each directory will have a metadata.json - that represents the main metadata for this entity 4. Can have other xyz.json for xyz specific attributes

func NewFileStorage

func NewFileStorage(storageDir string) *FileStorage

func (*FileStorage) AtomicSaveArtifact

func (f *FileStorage) AtomicSaveArtifact(id string, name string, m proto.Message) error

AtomicSaveArtifact saves an artifact atomically (write to temp, then rename)

func (*FileStorage) AtomicUpdate

func (f *FileStorage) AtomicUpdate(id string, name string, updateFn func(proto.Message) error, msgType proto.Message) error

AtomicUpdate performs an atomic read-modify-write operation

func (*FileStorage) CreateEntity

func (f *FileStorage) CreateEntity(customId string) (newId string, err error)

func (*FileStorage) DeleteEntity

func (f *FileStorage) DeleteEntity(id string) error

func (*FileStorage) EntityExists

func (f *FileStorage) EntityExists(id string) (exists bool, err error)

func (*FileStorage) LoadArtifact

func (f *FileStorage) LoadArtifact(id string, name string, m proto.Message) error

func (*FileStorage) ReadArtifactFile

func (f *FileStorage) ReadArtifactFile(id string, name string) ([]byte, error)

func (*FileStorage) SaveArtifact

func (f *FileStorage) SaveArtifact(id string, name string, m proto.Message) error

Jump to

Keyboard shortcuts

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