MongoEventQueryStorage

class MongoEventQueryStorage @JvmOverloads constructor(client: MongoClient, databaseName: String, val context: String, val options: MongoQueryOptions = MongoQueryOptions(), dispatcher: CoroutineDispatcher = VirtualThreads.dispatcher, readPreference: ReadPreference? = null, partitions: () -> Int? = { null }) : CachedQueryBindings<AggregateType>

The events query storage of one bounded context on MongoDB: the MongoSnapshotQueryBackend of each of its aggregate types over that aggregate's own log collection (wow_log__<ctx>__<agg>), which MongoEventLog appends to, its documents read as streams (MongoEventDocuments), with the facts of MongoEventStorageAdapter. One record per stream, as stored.

The log is the write store: its indexes are (partition, aggregate_id, tenant_id, version), (partition, tenant_id, request_id), (partition, sequence) and those of the access attributes, partial on the streams (MongoQueryIndexes.planLog). A query that pins its tenant and aggregates is given their partitions, by the log's own partition function over the log's partition count (partitions), so it reads the version key; a query under an access policy uses its attributes' indexes, and any other scans the aggregate type's collection. The entry's budget bounds it (maxTimeMS, sizes, the count limit). readPreference moves the reads off the primary (secondaryPreferred, say), at the cost of reading a little behind the appends; the primary's by default. An analytics-heavy deployment serves the model from ClickHouse or Elasticsearch.

Constructors

Link copied to clipboard
constructor(client: MongoClient, databaseName: String, context: String, options: MongoQueryOptions = MongoQueryOptions(), dispatcher: CoroutineDispatcher = VirtualThreads.dispatcher, readPreference: ReadPreference? = null, partitions: () -> Int? = { null })

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun collection(aggregateName: String): String

The log collection of aggregateName.