Package io.github.alexandrepiveteau.echo.core.log

Types

Link copied to clipboard
fun interface ChangeScope

An interface describing a ChangeScope. A ChangeScope defines a scope that lets users push some new changes, which will then be stored in a log and reverted as needed.

Link copied to clipboard
data class Event(    val seqno: SequenceNumber,     val site: SiteIdentifier,     val data: ByteArray) : Comparable<Event>

A class representing an Event. This will typically be used when a function should return a complete event, as well as its associated identifier.

Link copied to clipboard
interface EventIterator : ListIterator<Event>

An interface defining an iterator over a MutableEventLog. Efficient, allocation-free methods for iteration are available, as well as an implementation of ListIterator which returns Event objects on each iteration.

Link copied to clipboard
interface EventLog

An EventLog is a high-performance mutable log of serialized events, which are concatenated after each other in some contiguous data structures.

Link copied to clipboard
interface History<out T> : EventLog

A History is a high-performance log of serialized events, which aggregate the events into a current value which is incrementally computed from the linear sequence of events.

Link copied to clipboard
interface MutableEventIterator : EventIterator, MutableListIterator<Event>

A mutable variation of EventIterator, which may be used to mutate an underlying log of events.

Link copied to clipboard
interface MutableEventLog : EventLog

A MutableEventLog is an implementation of EventLog optimized for consecutive insertions and removals at the same index; this works particularly well when many events are appended to the end of a MutableEventLog, or when two MutableEventLog are merged.

Link copied to clipboard
interface MutableHistory<out T> : History<T> , MutableEventLog

A MutableHistory is a high-performance log of serialized events, which aggregate the events into a current value which is incrementally computed from the linear sequence of events.

Link copied to clipboard
interface MutableProjection<T>

A MutableProjection applies events to a model of type T. When events are applied with the forward method, some changes may be generated and issued to the ChangeScope. These changes will then be made available when the backward method is called.

Functions

Link copied to clipboard
fun EventLog.copyOf(): EventLog

Returns a copy of the current EventLog.

Link copied to clipboard
fun EventIterator.isEmpty(): Boolean

Returns true iff the EventIterator is empty.

fun EventLog.isEmpty(): Boolean

Returns true iff there are no events in the EventLog.

Link copied to clipboard
fun EventIterator.isNotEmpty(): Boolean

Returns true iff the EventIterator is not empty.

fun EventLog.isNotEmpty(): Boolean

Returns true iff there are some events in the EventLog.

Link copied to clipboard
inline fun EventIterator.movePreviousWhile(predicate: EventIterator.() -> Boolean)

Moves the EventIterator to the previous, while the predicate is valid.

Link copied to clipboard
fun EventIterator.moveToEnd()

Moves the EventIterator to its end, without allocations.

Link copied to clipboard
fun EventIterator.moveToStart()

Moves the EventIterator to its start, without allocations.

Link copied to clipboard
fun mutableEventLogOf(clock: Clock = Clock.System): MutableEventLog
fun mutableEventLogOf(vararg events: Event, clock: Clock = Clock.System): MutableEventLog
fun mutableEventLogOf(vararg events: Pair<EventIdentifier, ByteArray>, clock: Clock = Clock.System): MutableEventLog

Creates a new MutableEventLog, with no aggregate.

Link copied to clipboard
fun <T> mutableHistoryOf(    initial: T,     projection: MutableProjection<T>,     clock: Clock = Clock.System): MutableHistory<T>
fun <T> mutableHistoryOf(    initial: T,     projection: MutableProjection<T>,     vararg events: Pair<EventIdentifier, ByteArray>,     clock: Clock = Clock.System): MutableHistory<T>

Creates a new MutableHistory, with an aggregate with an initial value and a projection for incremental changes.

Link copied to clipboard
fun mutableTreeEventLogOf(clock: Clock = Clock.System): MutableEventLog
fun mutableTreeEventLogOf(vararg events: Event, clock: Clock = Clock.System): MutableEventLog
fun mutableTreeEventLogOf(vararg events: Pair<EventIdentifier, ByteArray>, clock: Clock = Clock.System): MutableEventLog

Creates a new MutableEventLog, with no aggregate.

Link copied to clipboard
fun EventLog.toList(): List<Event>

Transforms this EventLog to a List of Event.

Link copied to clipboard
fun EventLog.toMutableEventLog(): MutableEventLog

Returns a MutableEventLog copy of this EventLog.