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§
Sourcefn 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,
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§
Sourcefn 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 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 actioncontext
- Additional context for the callback
§Returns
Ok(true)
- Action is safe to executeOk(false)
- Action should be skippedErr(error)
- Safety check failed
Sourcefn 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,
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 checkcontext
- Additional context for the callback
§Returns
Ok(Some(capacity))
- Current capacity (e.g., number of instances)Ok(None)
- Unable to determine current capacityErr(error)
- Failed to check capacity