pub struct TemplateReloadRegistry { /* private fields */ }Expand description
Process-global registry of template reload targets.
Implementations§
Source§impl TemplateReloadRegistry
impl TemplateReloadRegistry
Sourcepub fn global() -> &'static TemplateReloadRegistry
pub fn global() -> &'static TemplateReloadRegistry
Process-global singleton (mirror of TlsReloadRegistry::global).
Sourcepub fn register(
&'static self,
target: Arc<dyn TemplateReloadTarget>,
) -> RegistrationGuard
pub fn register( &'static self, target: Arc<dyn TemplateReloadTarget>, ) -> RegistrationGuard
Register a target. The returned guard unregisters on drop (RAII).
Only callable on the global singleton: the guard
retains a &'static reference so it can evict its entry on drop from
any context.
Sourcepub fn find_all(&self, route_id: &str) -> Vec<Arc<dyn TemplateReloadTarget>>
pub fn find_all(&self, route_id: &str) -> Vec<Arc<dyn TemplateReloadTarget>>
All targets registered for route_id, in registration order.
pub so integration tests in camel-template can assert registration.
Sourcepub async fn reload_route(&self, route_id: &str) -> Result<(), CamelError>
pub async fn reload_route(&self, route_id: &str) -> Result<(), CamelError>
Reload ALL targets for route_id — all-or-nothing.
Acquires the per-route tokio::sync::Mutex (serializing concurrent
reload_route for the SAME route; different routes run in parallel).
Since there is no other reload path, no concurrent generation bump is
possible. Phases, in strict order:
- Build — run every target’s
buildconcurrently; if ANY returnsErr, abort (nothing committed). - Validate — every staged
read_genmust equal the target’scurrent_generation; any mismatch aborts (nothing committed). - Commit — only reached if all builds and validations succeeded;
commitis infallible, so atomicity is structural.
The whole sequence is bounded by the tightest target deadline; a
timeout returns Err and the dropped build futures never commit.