Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoSuchBias = errors.New("no such bias found")
)
Functions ¶
This section is empty.
Types ¶
type GCounter ¶
type GCounter struct {
// contains filtered or unexported fields
}
GCounter represent a G-counter in CRDT, which is a state-based grow-only counter that only supports increments.
func NewGCounter ¶
func NewGCounter() *GCounter
NewGCounter returns a *GCounter by pre-assigning a unique identity to it.
func (*GCounter) Count ¶
Count returns the total count of this counter across all the present replicas.
func (*GCounter) Inc ¶
func (g *GCounter) Inc()
Inc increments the GCounter by the value of 1 everytime it is called.
func (*GCounter) IncVal ¶
IncVal allows passing in an arbitrary delta to increment the current value of counter by. Only positive values are accepted. If a negative value is provided the implementation will panic.
func (GCounter) MarshalJSON ¶
MarshalJSON implements Marshaller on GCounter via a `jsonGCounter`
func (*GCounter) Merge ¶
Merge combines the counter values across multiple replicas. The property of idempotency is preserved here across multiple merges as when no state is changed across any replicas, the result should be exactly the same everytime.
func (*GCounter) UnmarshalJSON ¶
UnmarshalJSON implements unmarshaller on GCounter via a `jsonGCounter`
type GSet ¶
type GSet struct {
// contains filtered or unexported fields
}
Gset is a grow-only set.
func (*GSet) Add ¶
func (g *GSet) Add(elem interface{})
Add lets you add an element to grow-only set.
func (*GSet) Contains ¶
Contains returns true if an element exists within the set or false otherwise.
func (*GSet) Elems ¶
func (g *GSet) Elems() []interface{}
Elems returns all the elements present in the set.
func (*GSet) MarshalJSON ¶
MarshalJSON will be used to generate a serialized output of a given GSet.
type LWWSet ¶
type LWWSet struct {
// contains filtered or unexported fields
}
func NewLWWSetWithBias ¶
func (*LWWSet) MarshalJSON ¶
type PNCounter ¶
type PNCounter struct {
// contains filtered or unexported fields
}
PNCounter represents a state-based PN-Counter. It is implemented as sets of two G-Counters, one that tracks increments while the other decrements.
func NewPNCounter ¶
func NewPNCounter() *PNCounter
NewPNCounter returns a new *PNCounter with both its G-Counters initialized.
func (*PNCounter) Count ¶
Count returns the current value of the counter. It subtracts the value of negative G-Counter from the positive grow-only counter and returns the result. Because this counter can grow in either direction, negative integers as results are possible.
func (*PNCounter) Dec ¶
func (pn *PNCounter) Dec()
Dec monotonically decrements the current value of the PN-Counter by one.
func (*PNCounter) DecVal ¶
DecVal adds a decrement to the current value of PN-Counter by the value of delta decr. Similar to IncVal, the value of decr cannot be less than 0.
func (*PNCounter) Inc ¶
func (pn *PNCounter) Inc()
Inc monotonically increments the current value of the PN-Counter by one.
type TwoPhaseSet ¶
type TwoPhaseSet struct {
// contains filtered or unexported fields
}
TwoPhaseSet supports both addition and removal of elements to set.
func NewTwoPhaseSet ¶
func NewTwoPhaseSet() *TwoPhaseSet
NewTwoPhaseSet returns a new instance of TwoPhaseSet.
func (*TwoPhaseSet) Add ¶
func (t *TwoPhaseSet) Add(elem interface{})
Add inserts element into the TwoPhaseSet.
func (*TwoPhaseSet) Contains ¶
func (t *TwoPhaseSet) Contains(elem interface{}) bool
Contains returns true if the set contains the element. The set is said to contain the element if it is present in the add-set and not in the remove-set.
func (*TwoPhaseSet) MarshalJSON ¶
func (t *TwoPhaseSet) MarshalJSON() ([]byte, error)
MarshalJSON serializes TwoPhaseSet into an JSON array.
func (*TwoPhaseSet) Remove ¶
func (t *TwoPhaseSet) Remove(elem interface{})
Remove deletes the element from the set.