pub struct SectionBuilder { /* private fields */ }Expand description
Step accumulator handed to the closure of StepAccumulator::layered.
A SectionBuilder inherits every step-adding method from
StepAccumulator (to, process, set_header, map_body, nested
to_layered/layered, stop, …) but deliberately exposes no
.parameters(), no .route_layer() and no .build(), and carries
no route metadata. Deferred-parameter and whole-route-middleware misuse
therefore cannot be expressed inside a section.
§Example
Nested sections produce nested BuilderStep::Layered steps:
use camel_builder::{RouteBuilder, StepAccumulator};
use camel_core::route::BuilderStep;
use tower::limit::ConcurrencyLimitLayer;
let route = RouteBuilder::from("direct:a")
.route_id("doctest")
.layered(ConcurrencyLimitLayer::new(2), |section| {
section.layered(ConcurrencyLimitLayer::new(3), |inner| {
inner.to_layered("mock:b", ConcurrencyLimitLayer::new(4))
})
})
.build()
.unwrap();
match &route.steps()[0] {
BuilderStep::Layered { steps, .. } => match &steps[0] {
BuilderStep::Layered { steps, .. } => {
assert!(matches!(steps[0], BuilderStep::LayeredTo { .. }));
}
other => panic!("expected nested Layered, got {other:?}"),
},
other => panic!("expected Layered, got {other:?}"),
}Trait Implementations§
Source§impl StepAccumulator for SectionBuilder
impl StepAccumulator for SectionBuilder
fn steps_mut(&mut self) -> &mut Vec<BuilderStep>
fn to(self, endpoint: impl Into<String>) -> Self
fn process<F, Fut>(self, f: F) -> Self
fn process_fn(self, processor: BoxProcessor) -> Self
fn set_header(self, key: impl Into<String>, value: impl Into<Value>) -> Self
fn map_body<F>(self, mapper: F) -> Self
fn set_body<B>(self, body: B) -> Self
fn set_body_fn<F>(self, expr: F) -> Self
fn set_header_fn<F>(self, key: impl Into<String>, expr: F) -> Self
fn aggregate(self, config: AggregatorConfig) -> Self
Source§fn stop(self) -> Self
fn stop(self) -> Self
Stop processing this exchange immediately. No further steps in the
current pipeline will run. Read more
fn delay(self, duration: Duration) -> Self
fn delay_with_header( self, duration: Duration, header: impl Into<String>, ) -> Self
Source§fn log(self, message: impl Into<String>, level: LogLevel) -> Self
fn log(self, message: impl Into<String>, level: LogLevel) -> Self
Log a message at the specified level. Read more
Source§fn convert_body_to(self, target: BodyType) -> Self
fn convert_body_to(self, target: BodyType) -> Self
Convert the message body to the target type. Read more
fn stream_cache(self, threshold: usize) -> Self
Source§fn stream_cache_default(self) -> Self
fn stream_cache_default(self) -> Self
Source§fn marshal(self, format: impl Into<String>) -> Result<Self, CamelError>
fn marshal(self, format: impl Into<String>) -> Result<Self, CamelError>
Marshal the message body using the specified data format. Read more
Source§fn unmarshal(self, format: impl Into<String>) -> Result<Self, CamelError>
fn unmarshal(self, format: impl Into<String>) -> Result<Self, CamelError>
Unmarshal the message body using the specified data format. Read more
Source§fn validate(self, expression: impl Into<String>) -> Self
fn validate(self, expression: impl Into<String>) -> Self
Validate the exchange using a predicate expression. Read more
Source§fn script(self, language: impl Into<String>, script: impl Into<String>) -> Self
fn script(self, language: impl Into<String>, script: impl Into<String>) -> Self
Execute a script that can modify the exchange (headers, properties, body). Read more
Source§fn enrich(self, uri: impl Into<String>) -> Self
fn enrich(self, uri: impl Into<String>) -> Self
EIP-7 enrich: synchronous content enrichment via a resolved producer. Read more
Source§fn poll_enrich(self, uri: impl Into<String>, timeout_ms: u64) -> Self
fn poll_enrich(self, uri: impl Into<String>, timeout_ms: u64) -> Self
EIP-7 pollEnrich: blocking poll of a PollingConsumer with timeout. Read more
fn bean(self, name: impl Into<String>, method: impl Into<String>) -> Self
Source§fn to_layered(
self,
uri: impl Into<String>,
layer: impl ProcessorLayer + 'static,
) -> Self
fn to_layered( self, uri: impl Into<String>, layer: impl ProcessorLayer + 'static, ) -> Self
Send to
uri through a Tower middleware layer. Read moreSource§fn layered(
self,
layer: impl ProcessorLayer + 'static,
section: impl FnOnce(SectionBuilder) -> SectionBuilder,
) -> Self
fn layered( self, layer: impl ProcessorLayer + 'static, section: impl FnOnce(SectionBuilder) -> SectionBuilder, ) -> Self
Wrap a nested sub-pipeline in a Tower middleware layer. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for SectionBuilder
impl !UnwindSafe for SectionBuilder
impl Forget for SectionBuilder
impl Freeze for SectionBuilder
impl Move for SectionBuilder
impl Send for SectionBuilder
impl Sync for SectionBuilder
impl Unpin for SectionBuilder
impl UnsafeUnpin for SectionBuilder
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