pub struct EventRouterBuilder<S> { /* private fields */ }Expand description
Builder for constructing an event router.
Use the on_create, on_update, on_delete, and on methods to
register handlers, then call build to produce a
dispatch function compatible with AtrgApp::on_event.
Implementations§
Source§impl<S: Clone + Send + Sync + 'static> EventRouterBuilder<S>
impl<S: Clone + Send + Sync + 'static> EventRouterBuilder<S>
Sourcepub fn on_create<F, Fut>(
self,
collection: impl Into<String>,
handler: F,
) -> Self
pub fn on_create<F, Fut>( self, collection: impl Into<String>, handler: F, ) -> Self
Register a handler for create operations on a collection.
Sourcepub fn on_update<F, Fut>(
self,
collection: impl Into<String>,
handler: F,
) -> Self
pub fn on_update<F, Fut>( self, collection: impl Into<String>, handler: F, ) -> Self
Register a handler for update operations on a collection.
Sourcepub fn on_delete<F, Fut>(
self,
collection: impl Into<String>,
handler: F,
) -> Self
pub fn on_delete<F, Fut>( self, collection: impl Into<String>, handler: F, ) -> Self
Register a handler for delete operations on a collection.
Sourcepub fn on<F, Fut>(self, collection: impl Into<String>, handler: F) -> Self
pub fn on<F, Fut>(self, collection: impl Into<String>, handler: F) -> Self
Register a handler for ALL operations on a collection.
The handler will be called for create, update, and delete events on the specified collection.
Sourcepub fn build(
self,
) -> impl Fn(JetstreamEvent, S) -> BoxFuture<'static, Result<()>> + Send + Sync + 'static
pub fn build( self, ) -> impl Fn(JetstreamEvent, S) -> BoxFuture<'static, Result<()>> + Send + Sync + 'static
Build the router into a dispatch function compatible with AtrgApp::on_event.
The returned closure can be passed directly to AtrgApp::on_event(...).
Events that don’t match any registered route are silently ignored (with
a tracing::debug! log).
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for EventRouterBuilder<S>
impl<S> !RefUnwindSafe for EventRouterBuilder<S>
impl<S> Send for EventRouterBuilder<S>
impl<S> Sync for EventRouterBuilder<S>
impl<S> Unpin for EventRouterBuilder<S>
impl<S> UnsafeUnpin for EventRouterBuilder<S>
impl<S> !UnwindSafe for EventRouterBuilder<S>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more