meta

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 1 Imported by: 0

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

type File struct {
	ID   string
	Meta FileMeta
}

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 (f StoreMeta[T]) CurrentVersion() int32

func (StoreMeta[T]) GetEmbeddedData

func (f StoreMeta[T]) GetEmbeddedData() []byte

func (StoreMeta[T]) GetShards

func (f StoreMeta[T]) GetShards() []string

func (StoreMeta[T]) ModTime

func (f StoreMeta[T]) ModTime() time.Time

func (StoreMeta[T]) Size

func (f StoreMeta[T]) Size() int64

Jump to

Keyboard shortcuts

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