docs
Systems
Messaging
QuerySystem
Key Components

Overview

The QuerySystem is small and mostly data-driven. It has one coordinator, QueryFactory, and one message class, Query. The rest of the system defines keys, enums, and the query contract.

Coordinators

QueryFactory

Static entry point for callers. Each method:

  1. Creates a Query with a target Domain and QueryVerb.Get.
  2. Sets QueryKeys.QuerySubject in the input params to the matching QuerySubjects value.
  3. Calls BusUtility.AskAndGet with the matching result key, and returns the typed value.

QueryFactory does not hold state. It is the only class in the system that talks to the bus, and it does so through BusUtility (dependency).

Current methods:

  • GetCurrentPlatform() routes to Domain.Release.
  • GetTimeInLevel() routes to Domain.Level.
  • GetCurrentLevel() routes to Domain.Game.
  • GetGameSpeed() routes to Domain.Game.

Message classes

Query

The message that carries a request and its answer. Owns its Params for input, its Result for output, and its Status. Callers create it through QueryFactory or directly, then send it through BusUtility (dependency).

QueryKeys and QueryKeyNames

QueryKeyNames holds the string names. QueryKeys holds the typed ParamKey fields built from those names. Use QueryKeys in calls to Params.Set, Params.Get, and Params.Has.

Interfaces

IQuery

The contract for a query. The query bus (dependency) delivers IQuery instances to handlers, which read TargetDomain, Verb, and Params, then write Result and Status. Handlers registered by owning systems must follow the documented rule that they do not change state while answering.

No handler interface is defined in these blocks. Handler registration happens on the query bus, which is described in the Bus dependency.

Enums

  • QueryVerb: Get, Own, Has.
  • QueryStatus: Pending, Success, Failure.
  • QuerySubjects: Platform, Time, Level, Speed.

Interactions with dependencies

DependencyHow this system uses it
Contracts (Domain)Each query is addressed to a Domain. The query bus routes by it.
Params (Params, ParamKey)Holds the query's input and result values. QueryKeys supplies the keys.
Bus (BusUtility)QueryFactory sends queries and reads answers through AskAndGet.
Bus (QueryBus, BusRegistry)Routes each query to the handler for its domain, reached through the service locator.
Bus (MessageBus)Queues queries until a handler is registered and the domain is ready, then releases them in FIFO order.