WowShape

class WowShape<S : AutoCloseable>(partitions: Int, partitionOf: (Aggregates.Command) -> Int, options: WowShape.Options, open: () -> S, append: (S, List<Aggregates.Command>) -> BooleanArray, save: (S, List<Aggregates.Command>) -> BooleanArray) : AutoCloseable

Wow's own write path at its peak, the shape the node gives the store, with the driver alone:

  • a caller's command queues on its partition's lane (PartitionAppendQueue); a lane with no batch handed or in flight hands one at once, what it holds up to Options.maxBatch streams, fixed when handed;

  • Options.appenders committers each take the first batch handed and those handed meanwhile, whole, while the call holds fewer than Options.mergeMax streams (so a call carries up to mergeMax + maxBatch - 1), and append them with one call (append); a lane hands its next batch once its batch is written;

  • once a command's stream is in the log, its snapshot queues for Options.writers writers, each saving up to Options.writerMax rows a call (save), as the node's snapshot writes do (SnapshotWrites).

Each appender and writer has its own store connection (open). A caller (submit) waits for its command as Options.answer says: at its append (Answer.COMMITTED, as Wow's E1 answers, the writers saving behind) or once its snapshot was written too (Answer.SNAPSHOT, the default wait's). A store call that throws fails each command it carried. counters counts the streams appended and the snapshots saved, so a committed step can say whether its snapshots kept up.

Constructors

Link copied to clipboard
constructor(partitions: Int, partitionOf: (Aggregates.Command) -> Int, options: WowShape.Options, open: () -> S, append: (S, List<Aggregates.Command>) -> BooleanArray, save: (S, List<Aggregates.Command>) -> BooleanArray)

Types

Link copied to clipboard
enum class Answer : Enum<WowShape.Answer>

When a caller's command is answered.

Link copied to clipboard
object Companion
Link copied to clipboard
data class Options(val mergeMax: Int = MERGE_MAX, val answer: WowShape.Answer = Answer.SNAPSHOT, val appenders: Int = APPENDERS, val maxBatch: Int = MAX_BATCH, val writers: Int = WRITERS, val writerMax: Int = WRITER_MAX, val appendFill: Int? = null, val saveFill: Int? = null, val fillWaitNanos: Long = FILL_WAIT_NANOS)

The shape: Wow's defaults (AppendQueueOptions: two mergers, a lane's batch of 64, calls merged up to 512 streams; two snapshot writes in flight of up to 256 rows), mergeMax, appenders and writers the ones a what-if case varies. With appendFill and saveFill, a call holds that many streams or snapshots: it waits for them (fillWaitNanos at most, fillWaitOf the rate they arrive at) and takes no more than whole lanes' batches past them, so the calls are of a size given rather than of what is there, as the calibration's equal shape is; null, as Wow's take them.

Functions

Link copied to clipboard
open override fun close()

Stops: the appenders finish their calls, then the writers save what those appended; a command still queued (none, once every caller has its answer) fails. Then the store connections close.

Link copied to clipboard

The streams appended and the snapshots saved so far, cumulative, and the calls that wrote them: the append calls and the partitions they took streams of (a lane's batch is one partition's), and the save calls.

Link copied to clipboard

Queues command and waits for its answer (Options.answer): whether it was written.