Skip to main content

camel_api/
routing_slip.rs

1use std::sync::Arc;
2
3use crate::Exchange;
4
5pub type RoutingSlipExpression = Arc<dyn Fn(&Exchange) -> Option<String> + Send + Sync>;
6
7#[derive(Clone)]
8pub struct RoutingSlipConfig {
9    pub expression: RoutingSlipExpression,
10    pub uri_delimiter: String,
11    pub cache_size: i32,
12    pub ignore_invalid_endpoints: bool,
13}
14
15impl RoutingSlipConfig {
16    pub fn new(expression: RoutingSlipExpression) -> Self {
17        Self {
18            expression,
19            uri_delimiter: ",".to_string(),
20            cache_size: 1000,
21            ignore_invalid_endpoints: false,
22        }
23    }
24
25    pub fn uri_delimiter(mut self, d: impl Into<String>) -> Self {
26        self.uri_delimiter = d.into();
27        self
28    }
29
30    pub fn cache_size(mut self, n: i32) -> Self {
31        self.cache_size = n;
32        self
33    }
34
35    pub fn ignore_invalid_endpoints(mut self, ignore: bool) -> Self {
36        self.ignore_invalid_endpoints = ignore;
37        self
38    }
39}
40
41impl std::fmt::Debug for RoutingSlipConfig {
42    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
43        f.debug_struct("RoutingSlipConfig")
44            .field("uri_delimiter", &self.uri_delimiter)
45            .field("cache_size", &self.cache_size)
46            .field("ignore_invalid_endpoints", &self.ignore_invalid_endpoints)
47            .finish()
48    }
49}