Documentation
¶
Index ¶
- Constants
- Variables
- func CheckName(name string) error
- func CloneMark(ctx context.Context, st SpaceTx, from, to string) error
- func ForEach(ctx context.Context, stx SpaceTx, span Span, fn func(string) error) (retErr error)
- func GotFS(cfg DSConfig) *gotfs.Machine
- func GotVC(cfg DSConfig) *gotvc.Machine[Payload]
- func History(ctx context.Context, vcmach *VCMach, s stores.Reading, snapRef gdat.Ref, ...) error
- func IsExists(err error) bool
- func IsNotExist(err error) bool
- func SortAnnotations(s []Annotation)
- func Sync(ctx context.Context, src, dst *MarkTx, force bool) error
- func SyncSpaces(ctx context.Context, task SyncSpacesTask) error
- func TestSpace(t *testing.T, newSpace func(t testing.TB) Space)
- func TestSync(t *testing.T, setup func(testing.TB) Space)
- func ViewSnapshot(ctx context.Context, stx SpaceTx, se SnapExpr, fn func(vctx *ViewCtx) error) error
- type Annotation
- type ChunkingConfig
- type Chunking_CDConfig
- type Chunking_Fixed
- type DSConfig
- type ErrInvalidName
- type ErrRefIntegrity
- type FSConfig
- type FSMach
- type Info
- type MarkTx
- func (m *MarkTx) Apply(ctx context.Context, fn func([3]stores.RW, gdat.Ref) (gdat.Ref, error)) error
- func (m *MarkTx) Config() DSConfig
- func (mtx *MarkTx) FSRO() [2]stores.Reading
- func (mtx *MarkTx) FSRW() [2]stores.RW
- func (b *MarkTx) GotFS() *gotfs.Machine
- func (b *MarkTx) GotVC() *VCMach
- func (b *MarkTx) History(ctx context.Context, fn func(ref gdat.Ref, snap Snap) error) error
- func (b *MarkTx) Info() Info
- func (b *MarkTx) Load(ctx context.Context, dst *gdat.Ref) (bool, error)
- func (b *MarkTx) LoadFS(ctx context.Context, dst *gotfs.Root) (bool, error)
- func (mt *MarkTx) LoadSnap(ctx context.Context, dst *Snap) (bool, error)
- func (m *MarkTx) Modify(ctx context.Context, fn func(mctx ModifyCtx) (*Snap, error)) error
- func (mtx *MarkTx) RO() [3]stores.Reading
- func (m *MarkTx) Save(ctx context.Context, ref gdat.Ref) error
- func (mtx *MarkTx) VCRO() stores.Reading
- func (mtx *MarkTx) VCRW() stores.RW
- func (mtx *MarkTx) WO() [3]stores.Writing
- type Metadata
- type ModifyCtx
- type Payload
- type Salt
- type Snap
- type SnapExpr
- type SnapExpr_Exact
- type SnapExpr_Mark
- type SnapExpr_Offset
- type SnapInfo
- type Space
- type SpaceTx
- type Span
- type SyncSpacesTask
- type VCMach
- type ViewCtx
Constants ¶
const MaxNameLen = 1024
Variables ¶
var ( ErrNotExist = errors.New("mark does not exist") ErrExists = errors.New("a mark already exists by that name") )
Functions ¶
func ForEach ¶
ForEach is a convenience function which uses Space.List to call fn with all the mark names contained in span.
func IsNotExist ¶
func SortAnnotations ¶
func SortAnnotations(s []Annotation)
func SyncSpaces ¶
func SyncSpaces(ctx context.Context, task SyncSpacesTask) error
Types ¶
type Annotation ¶
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_Fixed ¶
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 ¶
type ErrInvalidName ¶
func (ErrInvalidName) Error ¶
func (e ErrInvalidName) Error() string
type ErrRefIntegrity ¶
func (ErrRefIntegrity) Error ¶
func (e ErrRefIntegrity) Error() string
type FSConfig ¶
type FSConfig struct {
Data ChunkingConfig `json:"data_chunking"`
Metadata Chunking_CDConfig `json:"metadata_chunking"`
}
Config contains all parameters.
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 (Info) AsMetadata ¶
type MarkTx ¶
type MarkTx struct {
// contains filtered or unexported fields
}
MarkTx scopes down a SpaceTx to a single Mark.
func (*MarkTx) Apply ¶
func (m *MarkTx) Apply(ctx context.Context, fn func([3]stores.RW, gdat.Ref) (gdat.Ref, error)) error
Apply calls fn with the Marks target Ref If the mark does not yet have a target, then the ref will be 0.
type Metadata ¶
type Metadata struct {
Config DSConfig `json:"config"`
Annotations []Annotation `json:"annotations"`
}
Metadata is non-volume, user-modifiable information associated with a mark.
type Salt ¶
type Salt [32]byte
Salt is a 32-byte salt
func (Salt) MarshalText ¶
func (*Salt) UnmarshalText ¶
type SnapExpr ¶
type SnapExpr interface {
GetSpace() string
// Resolve returns a valid Ref, which points to a Snapshot.
Resolve(ctx context.Context, stx SpaceTx) (*gdat.Ref, error)
// contains filtered or unexported methods
}
SnapExpr is a sum type representing the different ways to refer to a Snapshot in Got So far, there are 2 primitive ways - Exactly by Ref - By Mark And 1 higher-order way - By an offset from the result of a previous expression
func ParseSnapExpr ¶
type SnapExpr_Exact ¶
func ParseSnap_Exact ¶
func ParseSnap_Exact(x string) (*SnapExpr_Exact, error)
func (*SnapExpr_Exact) GetSpace ¶
func (se *SnapExpr_Exact) GetSpace() string
type SnapExpr_Mark ¶
func ParseSnap_Mark ¶
func ParseSnap_Mark(x string) (*SnapExpr_Mark, error)
func (SnapExpr_Mark) GetSpace ¶
func (se SnapExpr_Mark) GetSpace() string
func (SnapExpr_Mark) String ¶
func (se SnapExpr_Mark) String() string
type SnapExpr_Offset ¶
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 {
// Do calls fn to perform a transaction.
Do(ctx context.Context, modify bool, fn func(SpaceTx) error) error
}
A Space holds named gotcore.
type SpaceTx ¶
type SpaceTx interface {
// Create creates a new Mark at name in the Space.
// The mark will have md for initial metadata.
// An error is returned if the name already exists.
Create(ctx context.Context, name string, md Metadata) (*Info, error)
// Inspect returns all the info for a Mark
Inspect(ctx context.Context, name string) (*Info, error)
// SetMetadata sets the metadata for the Mark at name to md
SetMetadata(ctx context.Context, name string, md Metadata) error
// Delete deletes a Mark and all of it's metadata, the Snapshot is not removed.
Delete(ctx context.Context, name string) error
// All iterates over all the mark names.
All(context.Context) iter.Seq2[string, error]
// Store returns the space's underlying stores
// These can all be the same store, but each will be passed to different systems.
// 0: GotFS data stream
// 1: GotFS metadata
// 2: GotVC
Stores() [3]stores.RW
// SetTarget changes the mark so it points to a different snapshot
SetTarget(ctx context.Context, name string, ref gdat.Ref) error
// GetTarget retrieves the Snapshot referenced by gdat.Ref
GetTarget(ctx context.Context, name string, dst *gdat.Ref) (bool, error)
}
SpaceTx is a transaction on a Space
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.