MongoSnapshotQueryStorage

class MongoSnapshotQueryStorage @JvmOverloads constructor(client: MongoClient, databaseName: String, val context: String, val options: MongoQueryOptions = MongoQueryOptions(), dispatcher: CoroutineDispatcher = VirtualThreads.dispatcher, readPreference: ReadPreference? = null, storeDdl: Ddl = Ddl.AUTO, operationTimeout: Duration = MongoTimeouts.OPERATION) : CachedQueryBindings<AggregateType>

The snapshot query storage of one bounded context on MongoDB: the MongoSnapshotQueryBackend of each of its aggregate types, over that aggregate's own snapshot collection, which MongoSnapshotStore writes, with the facts MongoQuerySchemaAdapter reads from the collection; and the management of its query indexes (manageIndexes). readPreference moves the queries off the primary (secondaryPreferred, say), at the cost of reading snapshots a little behind the ones a command's default wait waited for; the primary's by default. The indexes are managed through the database as the stores read and write it (MongoDatabases), whatever the client's own read preference and write concern.

The queries read at the client's read concern (local by default), where the events queries read what a majority has committed (me.ahoo.wow.mongo.log.committed): a snapshot is folded from committed entries, so the worst a failover shows of one is an older state, never an entry that was not.

Constructors

Link copied to clipboard
constructor(client: MongoClient, databaseName: String, context: String, options: MongoQueryOptions = MongoQueryOptions(), dispatcher: CoroutineDispatcher = VirtualThreads.dispatcher, readPreference: ReadPreference? = null, storeDdl: Ddl = Ddl.AUTO, operationTimeout: Duration = MongoTimeouts.OPERATION)

Properties

Link copied to clipboard
Link copied to clipboard

Functions

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

The snapshot collection of aggregateName.

Link copied to clipboard

Manages indexes (planned by MongoQueryIndexes.plan for aggregates of this context) as MongoQueryOptions.indexDdl says. Blocking: a host calls it once at startup. auto makes sure of a missing collection as the snapshot store does (its format record and key) before it indexes it.