MutableHistory

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.

See also

Parameters

T

the type of the aggregate.

Functions

Link copied to clipboard
abstract fun acknowledge(from: EventLog): MutableEventLog

Acknowledges the latest SequenceNumber for each SiteIdentifier that the other MutableEventLog contains. The behavior of the acknowledgement will be similar to what the acknowledge method does.

abstract fun acknowledge(seqno: SequenceNumber, site: SiteIdentifier)

Acknowledges the given SequenceNumber for a SiteIdentifier. The behavior of the acknowledgement will be similar to what the insert method does.

Link copied to clipboard
abstract fun acknowledged(): EventIdentifierArray

Returns an EventIdentifierArray with all the acknowledgements that have been issued by this MutableEventLog. This EventIdentifierArray only contains one EventIdentifier per SiteIdentifier.

Link copied to clipboard
abstract fun append(    site: SiteIdentifier,     event: ByteArray,     from: Int = 0,     until: Int = event.size): EventIdentifier

Appends a new event in the MutableEventLog for the given SiteIdentifier. The MutableEventLog should be owned by the given SiteIdentifier, to ensure no duplicate insertions can occur.

Link copied to clipboard
abstract fun clear()

Clears the data of the MutableEventLog. This will not necessarily reset the acknowledged events, which will still act as a baseline for event insertions and appends.

Link copied to clipboard
open operator fun contains(id: EventIdentifier): Boolean

Returns true if the event with the event with the given EventIdentifier is included in the EventLog, or if any event with the same SiteIdentifier and a higher SequenceNumber has already been integrated.

abstract fun contains(seqno: SequenceNumber, site: SiteIdentifier): Boolean

Returns true if the event with the event with the given SiteIdentifier is included in the EventLog, or if any event with the same SiteIdentifier and a higher SequenceNumber has already been integrated.

Link copied to clipboard
open fun insert(event: Event)

Inserts the provided Event in the MutableEventLog at the appropriate index. If the event is already present, or an event with the same EventIdentifier has already been inserted, the insertion will simply be ignored.

abstract fun insert(    seqno: SequenceNumber,     site: SiteIdentifier,     event: ByteArray,     from: Int = 0,     until: Int = event.size)

Inserts the provided event in the MutableEventLog at the appropriate index. If the event is already present, or an event with the same SiteIdentifier has already been inserted, the insertion will simply be ignored.

Link copied to clipboard
abstract operator fun iterator(): EventIterator

Returns an EventIterator. The retrieved EventIterator will start at the beginning of the EventLog, and should not be used anymore if the underlying EventLog is modified.

abstract fun iterator(site: SiteIdentifier): EventIterator

Returns an EventIterator specific to a single site. The retrieved EventIterator will start at the beginning of the EventLog, and should not be used anymore if the underlying EventLog is modified.

Link copied to clipboard
abstract fun iteratorAtEnd(): EventIterator

Returns an EventIterator. The retrieved EventIterator will start at the end of the EventLog, and should not be used anymore if the underlying EventLog is modified.

abstract fun iteratorAtEnd(site: SiteIdentifier): EventIterator

Returns an EventIterator specific to a single site. The retrieved EventIterator will start at the end of the EventLog, and should not be used anymore if the underlying EventLog is modified.

Link copied to clipboard
abstract fun merge(from: EventLog): MutableEventLog

Merges this MutableEventLog another log. The merge operation has the following semantics :

Link copied to clipboard
abstract fun registerLogUpdateListener(listener: EventLog.OnLogUpdateListener)

Registers the provided OnLogUpdateListener to this EventLog.

Link copied to clipboard
abstract fun registerValueUpdateListener(listener: History.OnValueUpdateListener<T>)

Registers the provided OnValueUpdateListener to this History.

Link copied to clipboard
abstract fun remove(seqno: SequenceNumber, site: SiteIdentifier): Boolean

Removes the event with the given seqno and site, assuming it's present in the MutableEventLog. An event that is not present will not be removed, and will not be marked acknowledged by the MutableEventLog either.

Link copied to clipboard
abstract fun unregisterLogUpdateListener(listener: EventLog.OnLogUpdateListener)

Unregisters the provided OnLogUpdateListener from this EventLog.

Link copied to clipboard
abstract fun unregisterValueUpdateListener(listener: History.OnValueUpdateListener<T>)

Unregisters the provided OnValueUpdateListener to this History.

Properties

Link copied to clipboard
abstract val current: T

The current value of the aggregated History.

Link copied to clipboard
abstract val size: Int

Returns the count of events in the EventLog.