Documentation
¶
Index ¶
- func ListFSEntities[T proto.Message](f *FileStorage, validate func(entry T) bool) (entities []T, err error)
- func LoadFSArtifact[T proto.Message](f *FileStorage, id string, name string) (out T, err error)
- func NewRandomId(numChars ...int) (string, error)
- type FileStorage
- func (f *FileStorage) AtomicSaveArtifact(id string, name string, m proto.Message) error
- func (f *FileStorage) AtomicUpdate(id string, name string, updateFn func(proto.Message) error, ...) error
- func (f *FileStorage) CreateEntity(customId string) (newId string, err error)
- func (f *FileStorage) DeleteEntity(id string) error
- func (f *FileStorage) EntityExists(id string) (exists bool, err error)
- func (f *FileStorage) LoadArtifact(id string, name string, m proto.Message) error
- func (f *FileStorage) ReadArtifactFile(id string, name string) ([]byte, error)
- func (f *FileStorage) SaveArtifact(id string, name string, m proto.Message) error
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 NewRandomId ¶
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 ¶
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 (*FileStorage) ReadArtifactFile ¶
func (f *FileStorage) ReadArtifactFile(id string, name string) ([]byte, error)
func (*FileStorage) SaveArtifact ¶
Click to show internal directories.
Click to hide internal directories.