camel_api/unit_of_work.rs
1use serde::{Deserialize, Serialize};
2
3/// Per-route Unit of Work configuration.
4///
5/// When present on a `RouteDefinition`, wraps the route's Tower pipeline with
6/// an `ExchangeUoWLayer` that tracks in-flight exchanges and fires optional
7/// completion hooks.
8///
9/// The `Default` implementation yields `{ on_complete: None, on_failure: None }`,
10/// which is semantically equivalent to "no UoW behaviour". A `RouteDefinition`
11/// only gains UoW overhead when `unit_of_work` is `Some(config)` — a default
12/// config wrapped in `Some` will still install the layer (with no hooks).
13#[derive(Debug, Clone, Serialize, Deserialize, Default)]
14pub struct UnitOfWorkConfig {
15 /// URI of the producer to call when an exchange completes successfully.
16 /// Example: `"log:on-complete"`
17 pub on_complete: Option<String>,
18 /// URI of the producer to call when an exchange fails
19 /// (inner pipeline returned `Err(_)` or `exchange.has_error()` is true).
20 /// Example: `"log:on-failure"`
21 pub on_failure: Option<String>,
22}