QuerySchemaCatalog

class QuerySchemaCatalog(storages: QueryStorageLocator = QueryStorageLocator.NONE, compiler: QueryModelCompiler = QueryModelCompiler.of(), aggregates: Collection<AggregateType> = emptyList(), listener: QuerySchemaRefreshListener = QuerySchemaRefreshListener.NONE, datasets: QueryDatasets = QueryDatasets.NONE)

The Catalog: compiles the query schema of every aggregate model this instance serves, one provider per aggregate type and model, with its compiler (by default the model sources merged, see QueryModelCompiler.of). Each storage only reports its native facts, through the storage adapter storages locates. Gateways and point reads read their schema here.

Storage facts (indexes, mappings, validators) change outside deployments, so the catalog is revalidated periodically: each schema of aggregates is reloaded and published only if it compiles, otherwise the previous one stays and the failure is reported. A model without a backend, or whose backend reports an UnavailableQueryStorageAdapter, has nothing to load or revalidate: its provider fails every load and revalidation skips it. Each dataset of datasets is compiled as its QueryModel.DATASET model, and revalidated with them.

Constructors

Link copied to clipboard
constructor(storages: QueryStorageLocator = QueryStorageLocator.NONE, compiler: QueryModelCompiler = QueryModelCompiler.of(), aggregates: Collection<AggregateType> = emptyList(), listener: QuerySchemaRefreshListener = QuerySchemaRefreshListener.NONE, datasets: QueryDatasets = QueryDatasets.NONE)

Types

Link copied to clipboard
data class Status(val aggregate: String, val model: QueryModel, val version: String? = null, val error: String? = null)

The state of one schema: its content-hash version, or the error that kept it from loading.

Functions

Link copied to clipboard

The snapshot schema aggregateType's query policies are evaluated against when no backend serves its snapshot queries: compiled from its declaration over the in-memory storage's facts, so a state of it can be admitted in memory (me.ahoo.wow.query.state.SnapshotPolicyGateway) though it is never queried. It reads no storage, so it is not revalidated.

Link copied to clipboard

The schema provider of aggregateType's model, compiled once and shared by every reader.

Link copied to clipboard
suspend fun revalidate(aggregate: String? = null, model: QueryModel? = null): List<QuerySchemaCatalog.Status>

Reloads every schema now, only aggregate's and only its model's when given; a schema that fails to compile keeps its previous version. Concurrent reloads of one model share the one in flight.

Link copied to clipboard
suspend fun schema(aggregateType: AggregateType, model: QueryModel): QueryModelSchema

The current schema of aggregateType's model.

Link copied to clipboard
suspend fun versions(aggregate: String? = null): List<QuerySchemaCatalog.Status>

The current version of every schema (aggregate's only, when given), loading those not loaded yet.