Documentation
¶
Index ¶
- func IsDescendentOf[T Snapshotable](ctx context.Context, s stores.Reading, x, a Snapshot[T]) (bool, error)
- type Machine
- func (a *Machine[T]) Check(ctx context.Context, s stores.Reading, snap Snapshot[T], ...) error
- func (m *Machine[T]) ForEach(ctx context.Context, s stores.Reading, xs []Ref, ...) error
- func (ag *Machine[T]) GetSnapshot(ctx context.Context, s stores.Reading, ref Ref) (*Snapshot[T], error)
- func (a *Machine[T]) NewSnapshot(ctx context.Context, s stores.Writing, sp SnapshotParams[T]) (*Snapshot[T], error)
- func (mach *Machine[T]) NewZero(ctx context.Context, s stores.Writing, sp SnapshotParams[T]) (*Snapshot[T], error)
- func (mach *Machine[T]) Populate(ctx context.Context, s stores.Reading, start Snapshot[T], set stores.Set, ...) error
- func (ag *Machine[T]) PostSnapshot(ctx context.Context, s stores.Writing, x Snapshot[T]) (*Ref, error)
- func (ag *Machine[T]) RefFromSnapshot(snap Snapshot[T]) Ref
- func (ag *Machine[T]) Squash(ctx context.Context, s stores.RW, x Snapshot[T], n int) (*Snapshot[T], error)
- func (m *Machine[T]) Sync(ctx context.Context, src stores.Reading, dst stores.Writing, snap Snapshot[T], ...) error
- type Option
- type Parser
- type Ref
- type Snapshot
- type SnapshotParams
- type Snapshotable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDescendentOf ¶
func IsDescendentOf[T Snapshotable](ctx context.Context, s stores.Reading, x, a Snapshot[T]) (bool, error)
IsDescendentOf returns true if any of x's parents are equal to a.
Types ¶
type Machine ¶
type Machine[T Snapshotable] struct { // contains filtered or unexported fields }
func NewMachine ¶
func NewMachine[T Snapshotable](parse Parser[T], opts ...Option[T]) *Machine[T]
func (*Machine[T]) Check ¶
func (a *Machine[T]) Check(ctx context.Context, s stores.Reading, snap Snapshot[T], checkRoot func(T) error) error
Check ensures that snapshot is valid.
func (*Machine[T]) ForEach ¶
func (m *Machine[T]) ForEach(ctx context.Context, s stores.Reading, xs []Ref, fn func(Ref, Snapshot[T]) error) error
ForEach calls fn once for each Ref in the snapshot graph.
func (*Machine[T]) GetSnapshot ¶
func (ag *Machine[T]) GetSnapshot(ctx context.Context, s stores.Reading, ref Ref) (*Snapshot[T], error)
GetSnapshot retrieves the snapshot referenced by ref from the store.
func (*Machine[T]) NewSnapshot ¶
func (*Machine[T]) NewZero ¶
func (mach *Machine[T]) NewZero(ctx context.Context, s stores.Writing, sp SnapshotParams[T]) (*Snapshot[T], error)
NewZero creates a new snapshot with no parent
func (*Machine[T]) Populate ¶
func (mach *Machine[T]) Populate(ctx context.Context, s stores.Reading, start Snapshot[T], set stores.Set, rootFn func(T) error) error
Populate adds all the blobcache.CIDs reachable from start to set. This will not include the CID for start itself, which has not yet been computed.
func (*Machine[T]) PostSnapshot ¶
func (ag *Machine[T]) PostSnapshot(ctx context.Context, s stores.Writing, x Snapshot[T]) (*Ref, error)
PostSnapshot marshals the snapshot and posts it to the store
func (*Machine[T]) RefFromSnapshot ¶
RefFromSnapshot computes a ref for snap if it was posted to s. It only calls s.Hash and s.MaxSize; it does not mutate s.
type Option ¶
type Option[T Snapshotable] = func(a *Machine[T])
func WithSalt ¶
func WithSalt[T Snapshotable](salt *[32]byte) Option[T]
type Snapshot ¶
type Snapshot[T Snapshotable] struct { // N is the critical distance to the root. // N is 0 if there are no parents. // N is the max of the parents' N + 1. N uint64 // CreatedAt is the time the snapshot was created. CreatedAt tai64.TAI64 Parents []gdat.Ref // Creator is the ID of the user who created the snapshot. Creator inet256.ID // Payload is the thing being snapshotted. Payload T }
func ParseSnapshot ¶
func ParseSnapshot[T Snapshotable](data []byte, parser Parser[T]) (*Snapshot[T], error)
type SnapshotParams ¶
type SnapshotParams[T Snapshotable] struct { Parents []Snapshot[T] Creator inet256.ID CreatedAt tai64.TAI64 // Payload is the thing being snapshot Payload T }
SnapshotParams are the parameters required to create a new snapshot.