Struct GenericQueryRepository

Source
pub struct GenericQueryRepository<V, A>
where V: Query<A>, A: Aggregate,
{ /* private fields */ }
Expand description

This provides a simple query repository that can be used both to return deserialized views and to act as a query processor.

Implementations§

Source§

impl<V, A> GenericQueryRepository<V, A>
where V: Query<A>, A: Aggregate,

Source

pub fn new(query_name: &str, conn: Client) -> Self

Creates a new GenericQueryRepository that will store its’ views in the table named identically to the query_name value provided. This table should be created by the user previously (see /db/init.sql).

Source

pub fn with_error_handler(&mut self, error_handler: Box<dyn Fn(AggregateError)>)

Since inbound views cannot

Source

pub fn view_name(&self) -> String

Returns the originally configured view name.

Source

pub fn apply_events( &mut self, query_instance_id: &str, events: &[EventEnvelope<A>], )

Used to apply committed events to a view.

Source

pub fn load(&mut self, query_instance_id: String) -> Option<V>

Loads and deserializes a view based on the view id.

Trait Implementations§

Source§

impl<Q, A> QueryProcessor<A> for GenericQueryRepository<Q, A>
where Q: Query<A>, A: Aggregate,

Source§

fn dispatch(&mut self, query_instance_id: &str, events: &[EventEnvelope<A>])

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

Auto Trait Implementations§

§

impl<V, A> !Freeze for GenericQueryRepository<V, A>

§

impl<V, A> !RefUnwindSafe for GenericQueryRepository<V, A>

§

impl<V, A> !Send for GenericQueryRepository<V, A>

§

impl<V, A> !Sync for GenericQueryRepository<V, A>

§

impl<V, A> Unpin for GenericQueryRepository<V, A>
where V: Unpin, A: Unpin,

§

impl<V, A> !UnwindSafe for GenericQueryRepository<V, A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V