marks

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const MaxNameLen = 1024

Variables

View Source
var (
	ErrNotExist = errors.New("mark does not exist")
	ErrExists   = errors.New("a mark already exists by that name")
)

Functions

func CheckName

func CheckName(name string) error

func CleanupVolume

func CleanupVolume(ctx context.Context, vol Volume, info Info) error

Cleanup ensures that there are no unreachable blobs in volume.

func ForEach

func ForEach(ctx context.Context, s Space, span Span, fn func(string) error) (retErr error)

ForEach is a convenience function which uses Space.List to call fn with all the mark names contained in span.

func IsExists

func IsExists(err error) bool

func IsNotExist

func IsNotExist(err error) bool

func SortAnnotations

func SortAnnotations(s []Annotation)

func Sync

func Sync(ctx context.Context, src, dst *Mark, force bool) error

SyncVolumes syncs the contents of src to dst.

func SyncSpaces

func SyncSpaces(ctx context.Context, task SyncSpacesTask) error

func TestSpace

func TestSpace(t *testing.T, newSpace func(t testing.TB) Space)

Types

type Annotation

type Annotation struct {
	Key   string `json:"k"`
	Value string `json:"v"`
}

Annotation annotates a mark

func GetAnnotation

func GetAnnotation(as []Annotation, key string) (ret []Annotation)

type ChunkingConfig

type ChunkingConfig struct {
	CD  *Chunking_CDConfig `json:"cd,omitempty"`
	Max *Chunking_Fixed    `json:"fixed,omitempty"`
}

type Chunking_CDConfig

type Chunking_CDConfig struct {
	MeanSize int `json:"mean_size"`
	MaxSize  int `json:"max_size"`
}

type Chunking_Fixed

type Chunking_Fixed struct {
	Max uint32 `json:"max"`
	Min uint32 `json:"min"`
}

type DSConfig

type DSConfig struct {
	// Salt is a 32-byte salt used to derive the cryptographic keys for the mark.
	Salt Salt `json:"salt"`
	// GotFS contains all configuration for GotFS
	GotFS FSConfig `json:"fs"`
}

DSConfig holds all data structure parameters

func DefaultConfig

func DefaultConfig(public bool) DSConfig

func (DSConfig) Hash

func (cfg DSConfig) Hash() [32]byte

func (DSConfig) Marshal

func (cfg DSConfig) Marshal(out []byte) []byte

type ErrInvalidName

type ErrInvalidName struct {
	Name   string
	Reason string
}

func (ErrInvalidName) Error

func (e ErrInvalidName) Error() string

type FSConfig

type FSConfig struct {
	Data     ChunkingConfig    `json:"data_chunking"`
	Metadata Chunking_CDConfig `json:"metadata_chunking"`
}

Config contains all parameters.

type FSMach

type FSMach = gotfs.Machine

type Info

type Info struct {
	// Config holds the all the datastructure parameters
	Config DSConfig `json:"config"`
	// Annotations are arbitrary metadata associated with the mark.
	Annotations []Annotation `json:"annotations"`

	// CreatedAt is the time the mark was created.
	CreatedAt tai64.TAI64 `json:"created_at"`
}

Info is the metadata associated with a Mark.

func CreateIfNotExists

func CreateIfNotExists(ctx context.Context, r Space, k string, cfg Metadata) (*Info, error)

func (Info) AsMetadata

func (i Info) AsMetadata() Metadata

func (Info) Clone

func (i Info) Clone() Info

type Mark

type Mark struct {
	Volume Volume
	Info   Info
	// contains filtered or unexported fields
}

Mark associates metadata with a Volume.

func (*Mark) AsMetadata

func (b *Mark) AsMetadata() Metadata

func (*Mark) Config

func (m *Mark) Config() DSConfig

func (*Mark) GetTarget

func (b *Mark) GetTarget(ctx context.Context) (*Snap, Tx, error)

func (*Mark) GotFS

func (b *Mark) GotFS() *gotfs.Machine

func (*Mark) GotVC

func (b *Mark) GotVC() *VCMach

func (*Mark) History

func (b *Mark) History(ctx context.Context, fn func(ref gdat.Ref, snap Snap) error) error

func (*Mark) Modify

func (b *Mark) Modify(ctx context.Context, fn func(mctx ModifyCtx) (*Snap, error)) error

func (*Mark) SetTarget

func (b *Mark) SetTarget(ctx context.Context, src stores.Reading, snap Snap) error

SetTarget forcibly sets the root of the mark.

func (*Mark) ViewFS

func (b *Mark) ViewFS(ctx context.Context, fn func(mach *gotfs.Machine, stores stores.Reading, root gotfs.Root) error) error

type MemSpace

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

func (*MemSpace) Create

func (r *MemSpace) Create(ctx context.Context, name string, cfg Metadata) (*Info, error)

func (*MemSpace) Delete

func (r *MemSpace) Delete(ctx context.Context, name string) error

func (*MemSpace) Inspect

func (r *MemSpace) Inspect(ctx context.Context, name string) (*Info, error)

func (*MemSpace) List

func (r *MemSpace) List(ctx context.Context, span Span, limit int) (ret []string, _ error)

func (*MemSpace) Open

func (r *MemSpace) Open(ctx context.Context, name string) (*Mark, error)

func (*MemSpace) Set

func (r *MemSpace) Set(ctx context.Context, name string, cfg Metadata) error

type Metadata

type Metadata struct {
	Config      DSConfig     `json:"config"`
	Annotations []Annotation `json:"annotations"`
}

Metadata is non-volume, user-modifiable information associated with a mark.

func (Metadata) AsInfo

func (c Metadata) AsInfo() Info

func (Metadata) Clone

func (c Metadata) Clone() Metadata

Clone returns a deep copy of md

type ModifyCtx

type ModifyCtx struct {
	VC    *VCMach
	FS    *FSMach
	Store stores.RW
	Root  *Snap
}

ModifyCtx is the context passed to the modify function.

func (*ModifyCtx) Sync

func (mctx *ModifyCtx) Sync(ctx context.Context, srcs [3]stores.Reading, root Snap) error

Sync syncs a snapshot into the store

type Payload

type Payload struct {
	Root gotfs.Root
	Aux  []byte
}

Payload is the thing being snapshotted.

func ParsePayload

func ParsePayload(data []byte) (Payload, error)

func (Payload) Marshal

func (p Payload) Marshal(out []byte) []byte

func (*Payload) Unmarshal

func (p *Payload) Unmarshal(data []byte) error

type Salt

type Salt [32]byte

Salt is a 32-byte salt

func (Salt) MarshalText

func (s Salt) MarshalText() ([]byte, error)

func (*Salt) String

func (s *Salt) String() string

func (*Salt) UnmarshalText

func (s *Salt) UnmarshalText(data []byte) error

type Snap

type Snap = gotvc.Snapshot[Payload]

type SnapInfo

type SnapInfo struct {
	AuthoredAt tai64.TAI64  `json:"authored_at"`
	Authors    []inet256.ID `json:"authors"`

	Message string `json:"message"`
}

SnapInfo holds additional information about a snapshot. This is stored as json in the snapshot.

type Space

type Space interface {
	Create(ctx context.Context, name string, cfg Metadata) (*Info, error)
	Inspect(ctx context.Context, name string) (*Info, error)
	Set(ctx context.Context, name string, cfg Metadata) error
	Delete(ctx context.Context, name string) error
	List(ctx context.Context, span Span, limit int) ([]string, error)

	// Open returns a volume for viewing and modifying the mark contents.
	Open(ctx context.Context, name string) (*Mark, error)
}

A Space holds named marks.

func NewMem

func NewMem(newVolume func() volumes.Volume) Space

type Span

type Span struct {
	Begin string
	End   string
}

func TotalSpan

func TotalSpan() Span

func (Span) Contains

func (s Span) Contains(x string) bool

type SyncSpacesTask

type SyncSpacesTask struct {
	// Src is the space to read from.
	Src Space
	// Dst is the name ofthe space to write to.
	Dst Space

	// Filter is applied to src to determine what to copy.
	// If nil, then all marks are copied.
	Filter func(string) bool
	// MapName is applied to go from names in the Src space, to name in the Dst space.
	MapName func(string) string
}

SyncSpacesTask contains parameters needed to copy marks from one space to another.

type Tx

type Tx = volumes.Tx

type TxParams

type TxParams = volumes.TxParams

type VCMach

type VCMach = gotvc.Machine[Payload]

type Volume

type Volume = volumes.Volume

Jump to

Keyboard shortcuts

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