Package io.github.alexandrepiveteau.echo.core.causality

Types

Link copied to clipboard
value class EventIdentifier : Comparable<EventIdentifier>

An EventIdentifier uniquely identifies events and their causality relationships in a distributed system. It offers the properties of a Lamport timestamp, with a unique site identifier for each client to disambiguate duplicate timestamps.

Link copied to clipboard
class EventIdentifierArray

An array of event identifiers. When targeting the JVM, instances of this class are represented as long[].

Link copied to clipboard
abstract class EventIdentifierIterator : Iterator<EventIdentifier>

An Iterator that is specialized for EventIdentifier. On the JVM, the values will be represented as a long.

Link copied to clipboard
value class SequenceNumber : Comparable<SequenceNumber>

A sequence number is a monotonically increasing value defined for a site. It can be seen as a logical timestamp.

Link copied to clipboard
value class SiteIdentifier : Comparable<SiteIdentifier>

A SiteIdentifier is a unique identifier amongst all the sites in a distributed system. Two sites are guaranteed to have different SiteIdentifier.

Functions

Link copied to clipboard
fun EventIdentifierArray.binarySearch(    element: EventIdentifier,     fromIndex: Int = 0,     toIndex: Int = size): Int

Searches this EventIdentifierArray for the provided element using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined.

Link copied to clipboard
fun EventIdentifierArray.binarySearchBySite(    element: SiteIdentifier,     fromIndex: Int = 0,     toIndex: Int = size): Int

Searches this EventIdentifierArray for the provided element using the binary search algorithm. The array is expected to be sorted by site identifiers, otherwise the result is undefined.

Link copied to clipboard
fun EventIdentifierArray.copyInto(    destination: EventIdentifierArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size): EventIdentifierArray

Copies this array or its subrange into the destination array and returns that array.

Link copied to clipboard
fun EventIdentifier(seqno: SequenceNumber, site: SiteIdentifier): EventIdentifier

Builds a new EventIdentifier, for a given SequenceNumber and a given SiteIdentifier.

Link copied to clipboard
fun eventIdentifierArrayOf(): EventIdentifierArray

Creates an empty EventIdentifierArray.

Link copied to clipboard
fun maxOf(a: SequenceNumber, b: SequenceNumber): SequenceNumber

Returns the maximum SequenceNumber in a pair.

fun maxOf(    a: SequenceNumber,     b: SequenceNumber,     c: SequenceNumber): SequenceNumber

Returns the maximum SequenceNumber in a triple.

Link copied to clipboard
fun Random.nextSiteIdentifier(): SiteIdentifier

Gets the next random SiteIdentifier from the random number generator.

Link copied to clipboard
fun EventIdentifierArray.sort()

Sorts the array in-place.

Link copied to clipboard
inline fun SequenceNumber.takeOrElse(block: () -> SequenceNumber): SequenceNumber

If this SequenceNumber then this is returned, otherwise block is executed and its result is returned.

Link copied to clipboard
fun ULong.toEventIdentifier(): EventIdentifier

Creates an EventIdentifier from a ULong.

Link copied to clipboard

Returns a primitive array from a generic Array of EventIdentifier.

Link copied to clipboard
fun UInt.toSequenceNumber(): SequenceNumber

Creates a SequenceNumber from a UInt.

fun Instant.toSequenceNumber(): SequenceNumber
Link copied to clipboard
fun UInt.toSiteIdentifier(): SiteIdentifier

Creates a SiteIdentifier from the current Int.

Link copied to clipboard
fun EventIdentifierArray.toTypedArray(): Array<EventIdentifier>

Returns a typed object array containing all the elements of this primitive array.

Link copied to clipboard
fun SequenceNumber.toUInt(): UInt

Creates a UInt from a SequenceNumber.

fun SiteIdentifier.toUInt(): UInt

Creates an UInt from the current SiteIdentifier.

Link copied to clipboard
fun EventIdentifier.toULong(): ULong

Creates an ULong from an EventIdentifier.

Properties

Link copied to clipboard
val EventIdentifier.isSpecified: Boolean

false when this has SiteIdentifier.Unspecified or SequenceNumber.Unspecified.

val SequenceNumber.isSpecified: Boolean

false when this is SequenceNumber.Unspecified.

Link copied to clipboard
val EventIdentifier.isUnspecified: Boolean

false when this has SiteIdentifier.Unspecified or SequenceNumber.Unspecified.

val SequenceNumber.isUnspecified: Boolean

true when this is SequenceNumber.Unspecified.