Skip to main content

ScaleTrigger

Trait ScaleTrigger 

Source
pub trait ScaleTrigger: Send + Sync {
    // Required method
    fn scale_to<'life0, 'life1, 'async_trait>(
        &'life0 self,
        service: &'life1 str,
        replicas: u32,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Abstraction over “scale this service to N replicas”, implemented by the agent’s ServiceManager.

ProxyManager is constructed before the ServiceManager and the ServiceManager holds an Arc<ProxyManager> (one-way wiring), so the activator cannot hold a concrete ServiceManager without a reference cycle. This trait lets the activator depend only on the scale-up capability, which the ServiceManager provides via its existing scale_service method. The daemon installs a concrete trigger after both halves exist (see ProxyManager::set_activator).

Required Methods§

Source

fn scale_to<'life0, 'life1, 'async_trait>( &'life0 self, service: &'life1 str, replicas: u32, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Scale service to at least replicas running replicas.

§Errors

Returns a human-readable error if the scale-up could not be initiated.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ScaleTrigger for RwLock<ServiceManager>

Bridge the post-Arc::try_unwrap ServiceManager (which the daemon holds as Arc<RwLock<ServiceManager>>) into the proxy’s [ScaleTrigger] so the scale-to-zero activator can wake an idle service on the next inbound request.

Implementing the trait on RwLock<ServiceManager> lets the daemon’s Arc<RwLock<ServiceManager>> coerce directly to Arc<dyn ScaleTrigger> without any wrapper type. Each scale_to takes a short read guard and forwards to ServiceManager::scale_service (which itself routes through the cluster when one is configured).

Source§

fn scale_to<'life0, 'life1, 'async_trait>( &'life0 self, service: &'life1 str, replicas: u32, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§