pub struct StackBuilder<T: Send + Sync + Clone + 'static> { /* private fields */ }Expand description
Fluent builder for composing messaging middleware into a handler pipeline.
Middleware is applied in the order added — the first middleware added becomes the outermost wrapper and runs first on each message.
§Example
ⓘ
let stack = StackBuilder::new(base_handler)
.with(retry_mw)
.with(metrics_mw)
.with(dedup_mw)
.build();Implementations§
Source§impl<T: Send + Sync + Clone + 'static> StackBuilder<T>
impl<T: Send + Sync + Clone + 'static> StackBuilder<T>
Sourcepub fn new(base: Arc<dyn MessageHandler<T>>) -> Self
pub fn new(base: Arc<dyn MessageHandler<T>>) -> Self
Create a new builder wrapping the given base handler.
Sourcepub fn with<M: HandlerMiddleware<T> + 'static>(self, mw: M) -> Self
pub fn with<M: HandlerMiddleware<T> + 'static>(self, mw: M) -> Self
Add middleware to the stack.
Middleware is applied in the order added — the first middleware added becomes the outermost wrapper.
Sourcepub fn build(self) -> Arc<dyn MessageHandler<T>>
pub fn build(self) -> Arc<dyn MessageHandler<T>>
Build the fully-wrapped handler by applying all middleware.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for StackBuilder<T>
impl<T> !UnwindSafe for StackBuilder<T>
impl<T> Freeze for StackBuilder<T>
impl<T> Send for StackBuilder<T>
impl<T> Sync for StackBuilder<T>
impl<T> Unpin for StackBuilder<T>
impl<T> UnsafeUnpin for StackBuilder<T>
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