Documentation
¶
Overview ¶
Package tree implements an observed-remove rooted tree CRDT.
Index ¶
- Variables
- type Delta
- type Node
- type NodeID
- type ORTree
- func New(replicaID string) (*ORTree, error)
- func NewFromClock(state clock.State) (*ORTree, error)
- func NewFromClockWithOptions(state clock.State, options Options) (*ORTree, error)
- func NewFromSnapshot(saved snapshot.Snapshot) (*ORTree, error)
- func NewFromSnapshotWithOptions(saved snapshot.Snapshot, options Options) (*ORTree, error)
- func NewWithOptions(replicaID string, options Options) (*ORTree, error)
- func (t *ORTree) Add(parent NodeID, value []byte) (NodeID, Delta, error)
- func (t *ORTree) ApplyDelta(delta Delta) error
- func (t *ORTree) ClockState() clock.State
- func (t *ORTree) CompactTombstones(tags []NodeID) (int, error)
- func (t *ORTree) MarshalBinary() ([]byte, error)
- func (t *ORTree) MarshalBinaryWithClockState() ([]byte, clock.State, error)
- func (t *ORTree) MarshalJSON() ([]byte, error)
- func (t *ORTree) Merge(other *ORTree) error
- func (t *ORTree) Nodes() []Node
- func (t *ORTree) Remove(id NodeID) (Delta, error)
- func (t *ORTree) SnapshotCurrentState() (snapshot.Snapshot, error)
- func (t *ORTree) State() crdt.StateSnapshot
- func (t *ORTree) TombstoneTags() []NodeID
- func (t *ORTree) UnmarshalBinary(data []byte) error
- func (t *ORTree) UnmarshalBinaryWithLimits(data []byte, limits frame.DecoderLimits) error
- type Options
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidReplicaID = errors.New("tree: invalid replica ID") ErrNilTree = errors.New("tree: nil OR-Tree") ErrUnknownParent = errors.New("tree: unknown live parent") ErrUnknownNode = errors.New("tree: unknown live node") ErrInvalidDelta = errors.New("tree: invalid delta") ErrIncompleteState = errors.New("tree: incomplete OR-Tree state") ErrNodeConflict = errors.New("tree: conflicting node identity") ErrResourceLimit = errors.New("tree: OR-Tree resource limit exceeded") ErrUnsafeCompaction = errors.New("tree: unsafe OR-Tree tombstone compaction") )
Functions ¶
This section is empty.
Types ¶
type Delta ¶
type Delta struct {
// contains filtered or unexported fields
}
func UnmarshalDelta ¶
func UnmarshalDeltaWithLimits ¶
func UnmarshalDeltaWithLimits(data []byte, limits frame.DecoderLimits) (Delta, error)
func (Delta) MarshalBinary ¶
func (Delta) MarshalJSON ¶ added in v1.0.5
MarshalJSON returns a diagnostic summary for structured logs. It omits node values, identities, tombstone identities, and clock state.
type ORTree ¶
type ORTree struct {
// contains filtered or unexported fields
}
ORTree supports add and observed-remove. Moving a node is deliberately not an in-place operation: remove it and add a new instance under the new parent.
func NewFromClockWithOptions ¶ added in v1.0.10
NewFromClockWithOptions restores an OR-Tree clock with explicit retained-state limits. Persist the clock atomically with a complete state before reusing its replica ID.
func NewFromSnapshotWithOptions ¶ added in v1.0.10
NewFromSnapshotWithOptions restores an OR-Tree snapshot while retaining the application's local resource limits. A snapshot is not allowed to widen the receiver's memory budget.
func NewWithOptions ¶ added in v1.0.10
NewWithOptions constructs an OR-Tree with explicit retained-state limits.
func (*ORTree) ApplyDelta ¶
func (*ORTree) ClockState ¶
func (*ORTree) CompactTombstones ¶ added in v1.0.10
CompactTombstones removes exactly the requested tombstoned leaf nodes. Call it only after the current membership epoch has durably recorded exact acknowledgements, a post-compaction checkpoint, and retirement of old deltas. Any known child makes a deleted node a structural anchor, so the operation is all-or-nothing for that request.
func (*ORTree) MarshalBinary ¶
MarshalBinary returns a deterministic, bounded framed OR-Tree state.
func (*ORTree) MarshalBinaryWithClockState ¶
func (*ORTree) MarshalJSON ¶ added in v1.0.5
MarshalJSON returns a diagnostic summary for structured logs. It omits node values, identities, tombstone identities, and clock state.
func (*ORTree) SnapshotCurrentState ¶
func (*ORTree) State ¶
func (t *ORTree) State() crdt.StateSnapshot
func (*ORTree) TombstoneTags ¶ added in v1.0.10
TombstoneTags returns every retained deletion tag in canonical order. It is an exact-acknowledgement input, not proof that a tombstone is safe to compact.
func (*ORTree) UnmarshalBinary ¶
UnmarshalBinary validates the full state before atomically replacing t. Complete states additionally require every non-root parent to be present.
func (*ORTree) UnmarshalBinaryWithLimits ¶
func (t *ORTree) UnmarshalBinaryWithLimits(data []byte, limits frame.DecoderLimits) error
type Options ¶ added in v1.0.10
Options bounds retained OR-Tree state. Applications handling untrusted peers should set limits for the replication group rather than rely on process-wide memory availability.
func DefaultOptions ¶ added in v1.0.10
func DefaultOptions() Options
DefaultOptions returns conservative retention limits that align with one default frame's element and value limits.