Skip to main content

InstanceSelector

Trait InstanceSelector 

Source
pub trait InstanceSelector: Send + Sync {
    // Required methods
    fn reads_active_requests(&self) -> bool;
    fn select_instance(
        &self,
        instance_ids: &[u64],
        active_requests: &dyn Fn(u64) -> u64,
        preview: bool,
    ) -> Option<u64>;
}
Expand description

Picks one instance for a PushRouter routing mode.

PushRouter calls select_instance inside its admission lock when reads_active_requests is true, so it must not block.

Required Methods§

Source

fn reads_active_requests(&self) -> bool

Whether selection reads in-flight request counts. PushRouter then tracks them and reserves the chosen instance.

Source

fn select_instance( &self, instance_ids: &[u64], active_requests: &dyn Fn(u64) -> u64, preview: bool, ) -> Option<u64>

Pick one of instance_ids, which are ascending and non-empty. A preview must not advance any state, such as a rotation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§