pub struct LighthouseEngine {
config: Arc<RwLock<LighthouseConfig>>,
callbacks: LighthouseCallbacks,
command_tx: UnboundedSender<EngineCommand>,
command_rx: Option<UnboundedReceiver<EngineCommand>>,
status: Arc<RwLock<EngineStatus>>,
metrics_cache: Arc<RwLock<HashMap<ResourceId, ResourceMetrics>>>,
cooldown_tracker: Arc<RwLock<CooldownTracker>>,
}
Expand description
The main lighthouse autoscaling engine
Fields§
§config: Arc<RwLock<LighthouseConfig>>
§callbacks: LighthouseCallbacks
§command_tx: UnboundedSender<EngineCommand>
§command_rx: Option<UnboundedReceiver<EngineCommand>>
§status: Arc<RwLock<EngineStatus>>
§metrics_cache: Arc<RwLock<HashMap<ResourceId, ResourceMetrics>>>
§cooldown_tracker: Arc<RwLock<CooldownTracker>>
Implementations§
Source§impl LighthouseEngine
impl LighthouseEngine
Sourcepub fn new(config: LighthouseConfig, callbacks: LighthouseCallbacks) -> Self
pub fn new(config: LighthouseConfig, callbacks: LighthouseCallbacks) -> Self
Create a new lighthouse engine
Sourcepub fn handle(&self) -> LighthouseHandle
pub fn handle(&self) -> LighthouseHandle
Get a handle to send commands to the engine
Sourcepub async fn start(self) -> LighthouseResult<()>
pub async fn start(self) -> LighthouseResult<()>
Start the lighthouse engine (consumes self)
Sourceasync fn handle_command(&self, command: EngineCommand) -> LighthouseResult<()>
async fn handle_command(&self, command: EngineCommand) -> LighthouseResult<()>
Handle incoming commands
Sourceasync fn update_metrics(&self, metrics: ResourceMetrics) -> LighthouseResult<()>
async fn update_metrics(&self, metrics: ResourceMetrics) -> LighthouseResult<()>
Update metrics for a resource
Sourceasync fn update_config(
&self,
new_config: LighthouseConfig,
) -> LighthouseResult<()>
async fn update_config( &self, new_config: LighthouseConfig, ) -> LighthouseResult<()>
Update the engine configuration
Sourceasync fn get_recommendation(
&self,
resource_id: &ResourceId,
) -> LighthouseResult<Option<ScaleAction>>
async fn get_recommendation( &self, resource_id: &ResourceId, ) -> LighthouseResult<Option<ScaleAction>>
Get scaling recommendation for a specific resource
Sourceasync fn evaluate_policy(
&self,
metrics: &ResourceMetrics,
policy: &ScalingPolicy,
) -> LighthouseResult<Option<ScaleAction>>
async fn evaluate_policy( &self, metrics: &ResourceMetrics, policy: &ScalingPolicy, ) -> LighthouseResult<Option<ScaleAction>>
Evaluate a scaling policy against metrics
Sourceasync fn evaluate_all_resources(&self) -> LighthouseResult<()>
async fn evaluate_all_resources(&self) -> LighthouseResult<()>
Evaluate all resources and execute scaling actions
Sourceasync fn execute_scaling_action(
&self,
action: ScaleAction,
) -> LighthouseResult<()>
async fn execute_scaling_action( &self, action: ScaleAction, ) -> LighthouseResult<()>
Execute a scaling action
Auto Trait Implementations§
impl Freeze for LighthouseEngine
impl !RefUnwindSafe for LighthouseEngine
impl Send for LighthouseEngine
impl Sync for LighthouseEngine
impl Unpin for LighthouseEngine
impl !UnwindSafe for LighthouseEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more