SnapshotPolicyGateway

class SnapshotPolicyGateway(val aggregateType: AggregateType, schemaProvider: QueryModelSchemaProvider, policies: List<QueryPolicy>, val entryPolicy: QueryEntryPolicy = QueryEntryPolicy.DEFAULT) : QueryGateway

The snapshot query policies of an aggregate type no backend serves the snapshot queries of (@AggregateRoot(snapshot = false), snapshots in memory without wow.query.memory.enabled, an application's own stores): admitRecord admits a state as a me.ahoo.wow.query.DefaultQueryGateway of its snapshots would, under policies (the caller scope, the application's) against schemaProvider's snapshot schema (me.ahoo.wow.query.schema.QuerySchemaCatalog.policyProvider), so StateVisibility hides from a state read and the events model what those policies would hide from a snapshot query. It answers no query: every query fails, as its snapshots are not queried, and no route serves it.

Constructors

Link copied to clipboard
constructor(aggregateType: AggregateType, schemaProvider: QueryModelSchemaProvider, policies: List<QueryPolicy>, entryPolicy: QueryEntryPolicy = QueryEntryPolicy.DEFAULT)

Properties

Link copied to clipboard
open override val aggregateType: AggregateType
Link copied to clipboard
open override val entryPolicy: QueryEntryPolicy

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

Functions

Link copied to clipboard
open suspend override 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
open override fun aggregate(query: AggregationQuery, caller: QueryCaller): Flow<ObjectNode>

The groups of query, streamed.

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

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

Link copied to clipboard
open suspend override 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
open suspend override 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
open override fun list(query: ListQuery, caller: QueryCaller): Flow<ObjectNode>

The records query matches, streamed.

Link copied to clipboard
open suspend override 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
open suspend override 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 override fun single(query: SingleQuery, caller: QueryCaller): ObjectNode?

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