pub struct Processor<R: Reducer, D: Db, T, E: EventHandler<R::Event>> { /* private fields */ }Expand description
Implementations§
Source§impl<R: Reducer, D: Db, T: LogTracker<R::Op>, E: EventHandler<R::Event>> Processor<R, D, T, E>
impl<R: Reducer, D: Db, T: LogTracker<R::Op>, E: EventHandler<R::Event>> Processor<R, D, T, E>
Sourcepub async fn open(
reducer: R,
db: D,
prefix: &str,
self_id: Uuid,
) -> Result<Self, ProcessorError<R::Error>>
pub async fn open( reducer: R, db: D, prefix: &str, self_id: Uuid, ) -> Result<Self, ProcessorError<R::Error>>
Open a processor against db: set up HLC storage and the tracker (both
namespaced by prefix), seed the clock and cursor view from persisted
state, and take ownership of reducer.
Sourcepub async fn exec(
&self,
server_user_id: Option<Uuid>,
op: R::Op,
) -> Result<(), ProcessorError<R::Error>>
pub async fn exec( &self, server_user_id: Option<Uuid>, op: R::Op, ) -> Result<(), ProcessorError<R::Error>>
Apply a local write: mint a fresh entry under self_id and ingest it,
advancing self’s cursor.
Sourcepub fn event_handler(&self) -> &E
pub fn event_handler(&self) -> &E
The handler this processor emits into — subscribe off it.
Trait Implementations§
Source§impl<R: Reducer, D: Db, T: Send + Sync, E: EventHandler<R::Event> + Send + Sync> HasCursors for Processor<R, D, T, E>
impl<R: Reducer, D: Db, T: Send + Sync, E: EventHandler<R::Event> + Send + Sync> HasCursors for Processor<R, D, T, E>
Source§fn cursors<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<PeerCursors, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cursors<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<PeerCursors, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Snapshot of the current cursor vector.
Source§fn watch_cursors(&self) -> CursorStream
fn watch_cursors(&self) -> CursorStream
Source§impl<R: Reducer, D: Db, T: LogTracker<R::Op>, E: EventHandler<R::Event> + Send + Sync> LogProcessor<<R as Reducer>::Op> for Processor<R, D, T, E>
impl<R: Reducer, D: Db, T: LogTracker<R::Op>, E: EventHandler<R::Event> + Send + Sync> LogProcessor<<R as Reducer>::Op> for Processor<R, D, T, E>
Source§fn apply<'life0, 'async_trait>(
&'life0 self,
peer: Uuid,
index: u64,
entry: DecodedEntry<R::Op>,
) -> Pin<Box<dyn Future<Output = Result<Applied, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn apply<'life0, 'async_trait>(
&'life0 self,
peer: Uuid,
index: u64,
entry: DecodedEntry<R::Op>,
) -> Pin<Box<dyn Future<Output = Result<Applied, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Apply one entry at
(peer, index), advancing the cursor for peer to
index + 1. Idempotent (see the trait docs).Source§impl<R: Reducer, D: Db, T: HistoryTracker<R::Op>, E: EventHandler<R::Event> + Send + Sync> LogSource<<R as Reducer>::Op> for Processor<R, D, T, E>
impl<R: Reducer, D: Db, T: HistoryTracker<R::Op>, E: EventHandler<R::Event> + Send + Sync> LogSource<<R as Reducer>::Op> for Processor<R, D, T, E>
Source§fn read_since<'life0, 'async_trait>(
&'life0 self,
peer: Uuid,
from: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<(u64, DecodedEntry<R::Op>)>, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_since<'life0, 'async_trait>(
&'life0 self,
peer: Uuid,
from: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<(u64, DecodedEntry<R::Op>)>, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
A bounded batch of
peer’s entries at or after from, ascending
(expunged markers included). Empty means drained at from; the caller
loops with an advancing from until then.Source§impl<R: Reducer, D: Db, T: LogTracker<R::Op>> SqlStore<<R as Reducer>::Op, <R as Reducer>::Event> for Processor<R, D, T, EventBus<R::Event>>
impl<R: Reducer, D: Db, T: LogTracker<R::Op>> SqlStore<<R as Reducer>::Op, <R as Reducer>::Event> for Processor<R, D, T, EventBus<R::Event>>
Source§fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sql: &'life1 str,
params: &'life2 [DbValue],
) -> Pin<Box<dyn Future<Output = Result<Vec<DbRow>, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sql: &'life1 str,
params: &'life2 [DbValue],
) -> Pin<Box<dyn Future<Output = Result<Vec<DbRow>, DbError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Run a read-only query against the backend.
Source§fn dialect(&self) -> SqlDialect
fn dialect(&self) -> SqlDialect
The backend’s SQL dialect — lets a caller build dialect-correct SQL
(placeholder style, quoting) to hand back to
query.Source§impl<R: Reducer, D: Db, T: LogTracker<R::Op>> Store<<R as Reducer>::Op, ProcessorError<Box<dyn Error + Send + Sync>>, <R as Reducer>::Event> for Processor<R, D, T, EventBus<R::Event>>
impl<R: Reducer, D: Db, T: LogTracker<R::Op>> Store<<R as Reducer>::Op, ProcessorError<Box<dyn Error + Send + Sync>>, <R as Reducer>::Event> for Processor<R, D, T, EventBus<R::Event>>
Source§fn exec<'life0, 'async_trait>(
&'life0 self,
server_user_id: Option<Uuid>,
op: R::Op,
) -> Pin<Box<dyn Future<Output = Result<(), ProcessorError<BoxError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn exec<'life0, 'async_trait>(
&'life0 self,
server_user_id: Option<Uuid>,
op: R::Op,
) -> Pin<Box<dyn Future<Output = Result<(), ProcessorError<BoxError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Apply a local write, minting a fresh log entry for it.
Source§fn watch(
&self,
target: <R::Event as RoutableEvent>::Target,
) -> Subscription<R::Event>
fn watch( &self, target: <R::Event as RoutableEvent>::Target, ) -> Subscription<R::Event>
Subscribe to events routed to
target; dropping the subscription
unsubscribes.Auto Trait Implementations§
impl<R, D, T, E> !Freeze for Processor<R, D, T, E>
impl<R, D, T, E> !RefUnwindSafe for Processor<R, D, T, E>
impl<R, D, T, E> Send for Processor<R, D, T, E>
impl<R, D, T, E> Sync for Processor<R, D, T, E>
impl<R, D, T, E> Unpin for Processor<R, D, T, E>
impl<R, D, T, E> UnsafeUnpin for Processor<R, D, T, E>where
D: UnsafeUnpin,
T: UnsafeUnpin,
<E as EventHandler<<R as Reducer>::Event>>::Publish: UnsafeUnpin,
E: UnsafeUnpin,
R: UnsafeUnpin,
impl<R, D, T, E> UnwindSafe for Processor<R, D, T, E>where
D: UnwindSafe,
T: UnwindSafe,
<E as EventHandler<<R as Reducer>::Event>>::Publish: UnwindSafe,
E: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more