Trait ScalingExecutor

Source
pub trait ScalingExecutor: Send + Sync {
    // Required method
    fn execute_scale_action<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        action: &'life1 ScaleAction,
        context: &'life2 CallbackContext,
    ) -> Pin<Box<dyn Future<Output = LighthouseResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn is_safe_to_scale<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _action: &'life1 ScaleAction,
        _context: &'life2 CallbackContext,
    ) -> Pin<Box<dyn Future<Output = LighthouseResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn get_current_capacity<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _resource_id: &'life1 str,
        _context: &'life2 CallbackContext,
    ) -> Pin<Box<dyn Future<Output = LighthouseResult<Option<u32>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Trait for executing scaling actions

Implement this to actually perform scaling operations. This is where you integrate with your infrastructure (K8s, AWS, etc.).

Required Methods§

Source

fn execute_scale_action<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, action: &'life1 ScaleAction, context: &'life2 CallbackContext, ) -> Pin<Box<dyn Future<Output = LighthouseResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Execute a scaling action

§Arguments
  • action - The scaling action to perform
  • context - Additional context for the callback
§Returns
  • Ok(true) - Action was successfully executed
  • Ok(false) - Action was skipped (e.g., already at target scale)
  • Err(error) - Failed to execute action

Provided Methods§

Source

fn is_safe_to_scale<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _action: &'life1 ScaleAction, _context: &'life2 CallbackContext, ) -> Pin<Box<dyn Future<Output = LighthouseResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Check if a scaling action is safe to execute

This is called before execute_scale_action to provide a safety check. Use this to implement business rules, maintenance windows, etc.

§Arguments
  • action - The proposed scaling action
  • context - Additional context for the callback
§Returns
  • Ok(true) - Action is safe to execute
  • Ok(false) - Action should be skipped
  • Err(error) - Safety check failed
Source

fn get_current_capacity<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _resource_id: &'life1 str, _context: &'life2 CallbackContext, ) -> Pin<Box<dyn Future<Output = LighthouseResult<Option<u32>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get current capacity/state of a resource

This helps the engine understand the current state before scaling.

§Arguments
  • resource_id - The resource to check
  • context - Additional context for the callback
§Returns
  • Ok(Some(capacity)) - Current capacity (e.g., number of instances)
  • Ok(None) - Unable to determine current capacity
  • Err(error) - Failed to check capacity

Implementors§