package crdt
Type Members
-
trait
CommandContext extends CrdtContext with CrdtFactory with EffectContext with ClientActionContext
Context for handling a command.
Context for handling a command.
This may be passed to any
CommandHandlerannotated element. - class CommandHandler extends Annotation with Annotation with ClassfileAnnotation
-
trait
Crdt extends AnyRef
Root interface for all CRDTs.
-
trait
CrdtContext extends EntityContext
Root context for all CRDT contexts.
-
trait
CrdtCreationContext extends CrdtContext with CrdtFactory
Context for CRDT creation.
Context for CRDT creation.
This is available for injection into the constructor of a CRDT.
- class CrdtEntity extends Annotation with Annotation with ClassfileAnnotation
-
trait
CrdtEntityFactory extends AnyRef
Low level interface for handling commands for CRDTs.
Low level interface for handling commands for CRDTs.
Generally, this should not be used, rather, a
CrdtEntityannotated class should be used. -
trait
CrdtEntityHandler extends AnyRef
Low level interface for handling CRDT commands.
Low level interface for handling CRDT commands.
These are instantiated by a
CrdtEntityFactory.Generally, this should not be used, rather, a
CrdtEntityannotated class should be used. -
trait
CrdtFactory extends AnyRef
Factory for creating CRDTs.
Factory for creating CRDTs.
This is used both by CRDT contexts that allow creating CRDTs, as well as by CRDTs that allow nesting other CRDTs.
CRDTs may only be created by a supplied CRDT factory, CRDTs created any other way will not be known by the library and so won't have their deltas synced to and from the proxy.
-
trait
Flag extends Crdt
A flag CRDT.
A flag CRDT.
A flag is a boolean value that starts out as
false, and once set totrue, staystrue, it cannot be set back tofalse. -
trait
GCounter extends Crdt
A Grow-only Counter.
A Grow-only Counter.
A Grow-only Counter can be incremented, but can't be decremented.
-
trait
GSet[T] extends Crdt with Set[T]
A Grow-only Set.
A Grow-only Set.
A Grow-only Set can have elements added to it, but cannot have elements removed from it.
Care needs to be taken to ensure that the serialized value of elements in the set is stable. For example, if using protobufs, the serialized value of any maps contain in the protobuf is not stable, and can yield a different set of bytes for the same logically equal element. Hence maps, should be avoided. Additionally, some changes in protobuf schemas which are backwards compatible from a protobuf perspective, such as changing from sint32 to int32, do result in different serialized bytes, and so must be avoided.
-
trait
LWWRegister[T] extends Crdt
A Last-Write-Wins Register.
A Last-Write-Wins Register.
This uses a clock value to determine which of two concurrent writes should win. When both clock values are the same, an ordering defined over the node addresses is used to break the tie.
By default, the clock used is the clock of the node that set the value. This can be affected by clock skew, which means two successive writes delegated to two separate nodes could result in the first one winning. This can be avoided by using a custom clock with a domain specific clock value, if such a causally ordered value is available.
-
final
class
LWWRegisterMap[K, V] extends AbstractORMapWrapper[K, V, LWWRegister[V]] with Map[K, V]
Convenience wrapper class for
ORMapthat usesLWWRegister's for values.Convenience wrapper class for
ORMapthat usesLWWRegister's for values.This is useful as it allows the map to be used more idiomatically, with plain
Map#get(Object)andObject)calls for values. -
trait
ORMap[K, V <: Crdt] extends Crdt with Map[K, V]
An Observed-Removed Map.
An Observed-Removed Map.
An Observed-Removed Map allows both the addition and removal of objects in a map. A removal can only be done if all of the additions that caused the key to be in the map have been seen by this node. This means that, for example, if node 1 adds key A, and node 2 also adds key A, then node 1's addition is replicated to node 3, and node 3 deletes it before node 2's addition is replicated, then the item will still be in the map because node 2's addition had not yet been observed by node 3. However, if both additions had been replicated to node 3, then the key will be removed.
The values of the map are themselves CRDTs, and hence allow concurrent updates that will eventually converge. Values may only be inserted using the
Function)function, using theCrdtFactorypassed in to the creation callback. InvokingCrdt)or any other insertion method will throw aUnsupportedOperationException.While removing entries from the map is supported, if the entries are added back again, it is possible that the value of the deleted entry may be merged into the value of the current entry, depending on whether the removal has been replicated to all nodes before the addition is performed.
The map may contain different CRDT types as values, however, for a given key, the type must never change. If two different types for the same key are inserted on different nodes, the CRDT will enter an invalid state that can never be merged, and behavior of the CRDT is undefined.
Care needs to be taken to ensure that the serialized value of keys in the set is stable. For example, if using protobufs, the serialized value of any maps contained in the protobuf is not stable, and can yield a different set of bytes for the same logically equal element. Hence maps should be avoided. Additionally, some changes in protobuf schemas which are backwards compatible from a protobuf perspective, such as changing from sint32 to int32, do result in different serialized bytes, and so must be avoided.
-
trait
ORSet[T] extends Crdt with Set[T]
An Observed-Removed Set.
An Observed-Removed Set.
An Observed-Removed Set allows both the addition and removal of elements in a set. A removal can only be done if all of the additions that added the key have been seen by this node. This means that, for example if node 1 adds element A, and node 2 also adds element A, then node 1's addition is replicated to node 3, and node 3 deletes it before node 2's addition is replicated, then the element will still be in the map because node 2's addition had not yet been observed by node 3, and will cause the element to be re-added when node 3 receives it. However, if both additions had been replicated to node 3, then the element will be removed.
Care needs to be taken to ensure that the serialized value of elements in the set is stable. For example, if using protobufs, the serialized value of any maps contained in the protobuf is not stable, and can yield a different set of bytes for the same logically equal element. Hence maps should be avoided. Additionally, some changes in protobuf schemas which are backwards compatible from a protobuf perspective, such as changing from sint32 to int32, do result in different serialized bytes, and so must be avoided.
-
trait
PNCounter extends Crdt
A Positive-Negative Counter.
A Positive-Negative Counter.
A Positive-Negative Counter is a counter that allows both incrementing, and decrementing. It is based on two
GCounter's, a positive one that is incremented for every increment, and a negative one that is incremented for every decrement. The current value of the counter is calculated by subtracting the negative counter from the positive counter. -
final
class
PNCounterMap[K] extends AbstractORMapWrapper[K, Long, PNCounter] with Map[K, Long]
Convenience wrapper class for
ORMapthat usesPNCounter's for values. -
trait
StreamCancelledContext extends CrdtContext with EffectContext
Context for a stream cancelled event.
Context for a stream cancelled event.
This is sent to callbacks registered by
StreamedCommandContext#onCancel(Consumer). -
trait
StreamedCommandContext[Output] extends CommandContext
Context for handling a streamed command.
Context for handling a streamed command.
This may be passed to any
CommandHandlerannotated element that corresponds to a command whose output is streamed. -
trait
SubscriptionContext extends CrdtContext with EffectContext with ClientActionContext
The context for a subscription, passed with every invocation of a
StreamedCommandContext#onChange(Function)callback. -
trait
Vote extends Crdt
A Vote CRDT.
A Vote CRDT.
This CRDT is used to allow all the nodes in a cluster to vote on a condition.