-
Notifications
You must be signed in to change notification settings - Fork 20
Query
Duncan Jones edited this page Apr 10, 2021
·
5 revisions
The Query class is part of the CQRS Support in this event sourcing library. It allows for the creation of a special event stream backed entity which represents a query which is then used to implement and track the progress of that query.
You can instantiate a query in an Azure function via the Query Attribute
/// <summary>
/// List all accounts below a given threshold balance..
/// </summary>
/// <param name="req">
/// The HTTP request trigger with the parameters to use in the body as application/json
/// </param>
/// <remarks>
/// This sets up a new [Query], posts the
/// </remarks>
[FunctionName(nameof(AccountsBelowThresholdQuery))]
public static async Task<HttpResponseMessage> AccountsBelowThresholdQuery(
[HttpTrigger(AuthorizationLevel.Function, "POST", Route = @"AccountsBelowThresholdQuery")]HttpRequestMessage req,
[QueryAttribute("Bank","Accounts Below Threshold")] Query qryAccountsBelowThresholdQuery
)
{
// - - 8< - - - - - - - -
The events in the execution history of a query are:-
- Query Created - A new query has been created
- Parameter Value Set - A parameter to be used when executing the query has been set
- Output Location Set - A destination to return the results to was added
- Query Processing Requested - The query is ready for the actual work to be performed
- Query Completed - A multi-step (event stream backed) query has completed
In addition the query can request the execution of projection or classification and the events for this will be added to the query's underlying event stream
- Projection Requested - The query requested a projection to be run
- Projection Value Returned - The projection completed and results were made available to the query
- Classification Requested - The query requested a classification of an entity
- Classification Result Returned - The classifier was run over the requested entity event stream and results returned to the query
The built-in projections for a query are:-
- Output Locations - The set of places to send the results once the query completes