pub struct ScaleManager { /* private fields */ }Expand description
Tracks all instances managed by this Box host.
Implementations§
Source§impl ScaleManager
impl ScaleManager
Sourcepub fn process_request(&mut self, request: &ScaleRequest) -> ScaleResponse
pub fn process_request(&mut self, request: &ScaleRequest) -> ScaleResponse
Process a scale request and return the response.
This determines how many instances to create or destroy but does not actually start/stop VMs — the caller is responsible for that based on the response.
Sourcepub fn register_instance(
&mut self,
service: &str,
instance_id: &str,
endpoint: Option<&str>,
)
pub fn register_instance( &mut self, service: &str, instance_id: &str, endpoint: Option<&str>, )
Register a new instance for a service.
Sourcepub fn update_state(
&mut self,
service: &str,
instance_id: &str,
new_state: InstanceState,
) -> Option<InstanceEvent>
pub fn update_state( &mut self, service: &str, instance_id: &str, new_state: InstanceState, ) -> Option<InstanceEvent>
Update an instance’s state and emit a transition event.
Sourcepub fn update_health(
&mut self,
service: &str,
instance_id: &str,
health: InstanceHealth,
)
pub fn update_health( &mut self, service: &str, instance_id: &str, health: InstanceHealth, )
Update an instance’s health metrics.
Sourcepub fn update_endpoint(
&mut self,
service: &str,
instance_id: &str,
endpoint: &str,
)
pub fn update_endpoint( &mut self, service: &str, instance_id: &str, endpoint: &str, )
Update an instance’s endpoint.
Sourcepub fn deregister_instance(&mut self, service: &str, instance_id: &str) -> bool
pub fn deregister_instance(&mut self, service: &str, instance_id: &str) -> bool
Remove an instance from tracking.
Sourcepub fn instances_to_create(&self, service: &str) -> u32
pub fn instances_to_create(&self, service: &str) -> u32
Get instances that need to be created (target > current running).
Sourcepub fn instances_to_stop(&self, service: &str) -> Vec<String>
pub fn instances_to_stop(&self, service: &str) -> Vec<String>
Get instances that should be stopped (current > target). Returns instance IDs to stop, preferring non-busy instances.
Sourcepub fn ready_instances(&self, service: &str) -> Vec<InstanceInfo>
pub fn ready_instances(&self, service: &str) -> Vec<InstanceInfo>
Get all ready instances for a service (for traffic routing).
Sourcepub fn total_instances(&self) -> u32
pub fn total_instances(&self) -> u32
Get the total number of instances across all services.
Sourcepub fn service_instance_count(&self, service: &str) -> u32
pub fn service_instance_count(&self, service: &str) -> u32
Get the number of instances for a specific service.
Sourcepub fn recent_events(&self, limit: usize) -> &[InstanceEvent]
pub fn recent_events(&self, limit: usize) -> &[InstanceEvent]
Get recent events.
Sourcepub fn service_health(&self, service: &str) -> ServiceHealth
pub fn service_health(&self, service: &str) -> ServiceHealth
Aggregate health metrics for a service (for autoscaler decisions).
Sourcepub fn start_drain(
&mut self,
service: &str,
instance_id: &str,
) -> Option<InstanceEvent>
pub fn start_drain( &mut self, service: &str, instance_id: &str, ) -> Option<InstanceEvent>
Initiate graceful drain for an instance.
Transitions the instance to Draining state. The caller should:
- Stop routing new requests to this instance
- Wait for in-flight requests to complete (or timeout)
- Call
complete_drain()to transition toStopping
Sourcepub fn complete_drain(
&mut self,
service: &str,
instance_id: &str,
) -> Option<InstanceEvent>
pub fn complete_drain( &mut self, service: &str, instance_id: &str, ) -> Option<InstanceEvent>
Complete a drain and transition to Stopping.
Called after in-flight requests have completed or the drain timeout expired.
Sourcepub fn is_drain_complete(&self, service: &str, instance_id: &str) -> bool
pub fn is_drain_complete(&self, service: &str, instance_id: &str) -> bool
Check if a draining instance has no in-flight requests.
Sourcepub fn draining_instances(&self, service: &str) -> Vec<String>
pub fn draining_instances(&self, service: &str) -> Vec<String>
Get all instances currently draining.
Auto Trait Implementations§
impl Freeze for ScaleManager
impl RefUnwindSafe for ScaleManager
impl Send for ScaleManager
impl Sync for ScaleManager
impl Unpin for ScaleManager
impl UnsafeUnpin for ScaleManager
impl UnwindSafe for ScaleManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more