Documentation
¶
Overview ¶
Package meta implements the functions, types, and interfaces for the module.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batcher ¶
type Batcher interface {
// BatchGet retrieves multiple FileMeta objects by their IDs. It must handle different versions for backward compatibility.
BatchGet(ids []string) (map[string]FileMeta, error)
// BatchUpdate overwrites multiple existing FileMeta objects.
BatchUpdate(fileMetas map[string]FileMeta) error
}
Batcher defines an optional interface for stores that support efficient batch operations. A type that implements Store can also choose to implement Batcher.
type File ¶
A File is a domain object that represents a fully managed file. It brings together the file's ID and its metadata.
type FileMeta ¶
type FileMeta interface {
// CurrentVersion returns the version number of this metadata record.
CurrentVersion() int32
// Size returns the byte size of the file contents.
Size() int64
// ModTime returns when the contents of the file itself were last modified.
ModTime() time.Time
// GetEmbeddedData returns the raw byte data if the file content is embedded directly in the metadata.
// It returns nil if the content is not embedded.
GetEmbeddedData() []byte
// GetShards returns a list of blob hashes if the file content is stored in external blobs (shards).
// It returns nil if the content is embedded or the file is empty.
GetShards() []string
}
type FileMetaVersion ¶
type FileMetaVersion struct {
Version int32 `msgpack:"v"`
}
func (FileMetaVersion) CurrentVersion ¶
func (f FileMetaVersion) CurrentVersion() int32
type Store ¶
type Store interface {
// Create persists a new FileMeta object using a pre-determined, content-derived ID.
// The caller is responsible for generating the correct ID.
Create(id string, fileMeta FileMeta) error
// Get retrieves a FileMeta object by its ID. It must handle different versions for backward compatibility.
Get(id string) (FileMeta, error)
// Exists checks if a FileMeta object with the given ID exists.
Exists(id string) (bool, error)
// Update overwrites an existing FileMeta object.
Update(id string, fileMeta FileMeta) (FileMeta, error)
// Delete removes a FileMeta object by its ID.
Delete(id string) error
// Migrate migrates a FileMeta object from a previous version to the current version.
Migrate(id string) (FileMeta, error)
// CurrentVersion returns the version number used for writing new metadata.
CurrentVersion() int
}
Store defines the interface for a low-level, persistent key-value store for metadata objects.
type StoreMeta ¶
type StoreMeta[T FileMeta] struct { Version int32 `json:"version" msgpack:"v"` Data T `json:"data" msgpack:"d"` }
func (StoreMeta[T]) CurrentVersion ¶
func (StoreMeta[T]) GetEmbeddedData ¶
Click to show internal directories.
Click to hide internal directories.