Struct persist_es::GenericQuery[][src]

pub struct GenericQuery<R, V, A> where
    R: ViewRepository<V, A>,
    V: View<A>,
    A: Aggregate
{ /* fields omitted */ }
Expand description

A simple query and view repository. This is used both to act as a Query for processing events and to return materialized views.

Implementations

Creates a new GenericQuery using the provided ViewRepository.

let repo: MyRepo = ...
let query = GenericQuery::<MyRepo, MyView, MyAggregate>::new(repo);
let store = ...
let cqrs = CqrsFramework::new(store, vec![Box::new(query)]);

Allows the user to apply a custom error handler to the query. Queries are infallible and should never cause errors, but programming errors or other technical problems might. Adding an error handler allows the user to choose whether to panic the application, log the error or otherwise register the issue.

This is not required for usage but without an error handler any error encountered by the query repository will simply be ignored, so it is strongly recommended.

An error handler that panics on any error.

query.use_error_handler(Box::new(|e|panic!("{}",e)));

Loads and deserializes a view based on the provided view id. Use this method to load a materialized view when requested by a user.

This is an asynchronous method so don’t forget to await.

let view = query.load("customer-B24DA0".to_string()).await;

Trait Implementations

Events will be dispatched here immediately after being committed for the downstream queries to be updated. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.