Skip to main content

VibeNode

Struct VibeNode 

Source
pub struct VibeNode {
    pub node_id: NodeId,
    pub task_queue: VibeQueue<Task>,
    pub min_threads: usize,
    pub max_threads: usize,
    pub scale_down_cooldown: u64,
    /* private fields */
}
Expand description

A processing unit that executes tasks.

Each VibeNode contains a task queue and a dynamic pool of worker threads. It reports its status (e.g., overloaded, idle) to the central system, which helps with load balancing.

Fields§

§node_id: NodeId

A unique identifier for this node.

§task_queue: VibeQueue<Task>

The queue that holds tasks waiting to be executed by this node.

§min_threads: usize

The minimum number of worker threads to keep alive.

§max_threads: usize

The maximum number of worker threads this node can spawn.

§scale_down_cooldown: u64

A cooldown period to prevent scaling down threads too aggressively.

Implementations§

Source§

impl VibeNode

Source

pub fn new( node_id: NodeId, queue_capacity: usize, min_threads: usize, max_threads: usize, signal_tx: Sender<SystemSignal>, scale_down_cooldown_override: Option<u64>, ) -> Result<Self, String>

Creates and initializes a new VibeNode.

This sets up the task queue, thread limits, and spawns the minimum number of worker threads to start processing tasks.

Source

pub fn get_pressure(&self) -> usize

Returns the current pressure of the node (a percentage from 0 to 100).

Source

pub fn max_pressure(&self) -> usize

Returns the maximum possible pressure value (always 100).

Source

pub fn get_pressure_level(&self) -> PressureLevel

Returns a qualitative PressureLevel based on the current numeric pressure.

Source

pub fn shutdown(&self)

Begins the shutdown process for the node.

This closes the task queue to new submissions and waits for all existing worker threads to finish their current tasks and exit gracefully.

Source

pub fn id(&self) -> NodeId

Returns the node’s unique ID.

Source

pub fn active_threads(&self) -> usize

Returns the current number of active worker threads.

Source

pub fn desired_threads(&self) -> usize

Returns the desired number of worker threads.

Trait Implementations§

Source§

impl Drop for VibeNode

Source§

fn drop(&mut self)

Ensures the node is properly shut down when it goes out of scope.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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<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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.