Skip to main content

ScaleManager

Struct ScaleManager 

Source
pub struct ScaleManager { /* private fields */ }
Expand description

Tracks all instances managed by this Box host.

Implementations§

Source§

impl ScaleManager

Source

pub fn new(max_instances: u32) -> Self

Create a new scale manager with the given capacity.

Source

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.

Source

pub fn register_instance( &mut self, service: &str, instance_id: &str, endpoint: Option<&str>, )

Register a new instance for a service.

Source

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.

Source

pub fn update_health( &mut self, service: &str, instance_id: &str, health: InstanceHealth, )

Update an instance’s health metrics.

Source

pub fn update_endpoint( &mut self, service: &str, instance_id: &str, endpoint: &str, )

Update an instance’s endpoint.

Source

pub fn deregister_instance(&mut self, service: &str, instance_id: &str) -> bool

Remove an instance from tracking.

Source

pub fn instances_to_create(&self, service: &str) -> u32

Get instances that need to be created (target > current running).

Source

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.

Source

pub fn ready_instances(&self, service: &str) -> Vec<InstanceInfo>

Get all ready instances for a service (for traffic routing).

Source

pub fn total_instances(&self) -> u32

Get the total number of instances across all services.

Source

pub fn service_instance_count(&self, service: &str) -> u32

Get the number of instances for a specific service.

Source

pub fn services(&self) -> Vec<String>

List all tracked services.

Source

pub fn recent_events(&self, limit: usize) -> &[InstanceEvent]

Get recent events.

Source

pub fn service_health(&self, service: &str) -> ServiceHealth

Aggregate health metrics for a service (for autoscaler decisions).

Source

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:

  1. Stop routing new requests to this instance
  2. Wait for in-flight requests to complete (or timeout)
  3. Call complete_drain() to transition to Stopping
Source

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.

Source

pub fn is_drain_complete(&self, service: &str, instance_id: &str) -> bool

Check if a draining instance has no in-flight requests.

Source

pub fn draining_instances(&self, service: &str) -> Vec<String>

Get all instances currently draining.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more