QueryGateway

interface QueryGateway

The queries of one aggregate type's read model, each run for an explicit QueryCaller: admitted (QueryAdmission), executed on the backend's four primitives (BackendQueries.kt) within the timeout the caller's budget gives, and observed. Records are JSON trees as the model stores them; a caller that wants a type reads them with WowJson.

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

The entry policy this gateway admits every query under: the one source of each entry's budget.

Functions

Link copied to clipboard
open suspend fun admitRecord(selection: FilterExpression, record: ObjectNode, caller: QueryCaller): ObjectNode?

The single-aggregate visibility check of the policy chain: record, the snapshot-shaped record of one aggregate a point read chose by selection (a state read by id, its version or its trace, or the aggregate of an events query), as caller may read it: admitted by the same caller scope and QueryPolicy restrictions and the model's default scope as a query, evaluated in memory, and masked; null when the caller may not read it, so a row a query hides is hidden from a read by id too. A gateway without policies admits every record.

Link copied to clipboard
abstract fun aggregate(query: AggregationQuery, caller: QueryCaller): Flow<ObjectNode>

The groups of query, streamed.

Link copied to clipboard
abstract suspend fun count(query: CountQuery, caller: QueryCaller): CountResult

How many records query matches, bounded by its limit or its budget's.

Link copied to clipboard
abstract suspend fun cursor(query: CursorQuery, caller: QueryCaller): CursorPage<ObjectNode>

One keyset page of the records query matches, with the cursor of the next one.

Link copied to clipboard
abstract suspend fun describe(entry: QueryEntry, defaultListSize: Int? = null): QueryModelDescriptor

How this model can be queried on entry (the GET of the query route): the capability descriptor of the schema this gateway admits against, under the budget entryPolicy gives entry. defaultListSize is the list size the entry's adapter applies when a list query sends none, or null. Its version is the route's ETag.

Link copied to clipboard
abstract fun list(query: ListQuery, caller: QueryCaller): Flow<ObjectNode>

The records query matches, streamed.

Link copied to clipboard
open suspend fun maskRecord(record: ObjectNode): ObjectNode

record, the snapshot-shaped record of one aggregate, masked as this model's records are and admitted by no policy: a state of the history of an aggregate admitRecord admitted, read as the aggregate is now.

Link copied to clipboard
abstract suspend fun paged(query: PagedQuery, caller: QueryCaller): PagedList<ObjectNode>

One page of the records query matches, with its total as PagedQuery.total asks.

Link copied to clipboard
open suspend fun resumes(query: ListQuery): Boolean

Whether query streams as a resumable stream (stream): its model's storage pages by keyset and its sort, with the model's unique key appended, orders a cursor. A list that does not is streamed by list.

Link copied to clipboard
abstract suspend fun single(query: SingleQuery, caller: QueryCaller): ObjectNode?

The first record query matches, or null when none does.

Link copied to clipboard
open fun stream(query: ListQuery, caller: QueryCaller, after: String? = null, chunkSize: Int = DEFAULT_STREAM_CHUNK_SIZE): Flow<PositionedRecord>

The records query matches as a resumable stream: keyset chunks of chunkSize records read one after the other, each record with the cursor token of its position, from strictly after the position after names when given. after is a token of this model and effective sort (a stream's or a cursor query's); any other is wow.query.invalid. The query is admitted like a cursor query, so a stream resumed with the same query from another node or after a restart reads on from the same place, under its caller's scope again; at most query's limit records are read (0: all of them), and its budget bounds neither the limit nor the chunks. Each chunk runs within the query's timeout and under one bulkhead permit, given back before its records are emitted. Chunks are not one snapshot: see chunks. Only for a query resumes.