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: NodeIdA unique identifier for this node.
task_queue: VibeQueue<Task>The queue that holds tasks waiting to be executed by this node.
min_threads: usizeThe minimum number of worker threads to keep alive.
max_threads: usizeThe maximum number of worker threads this node can spawn.
scale_down_cooldown: u64A cooldown period to prevent scaling down threads too aggressively.
Implementations§
Source§impl VibeNode
impl VibeNode
Sourcepub 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>
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.
Sourcepub fn get_pressure(&self) -> usize
pub fn get_pressure(&self) -> usize
Returns the current pressure of the node (a percentage from 0 to 100).
Sourcepub fn max_pressure(&self) -> usize
pub fn max_pressure(&self) -> usize
Returns the maximum possible pressure value (always 100).
Sourcepub fn get_pressure_level(&self) -> PressureLevel
pub fn get_pressure_level(&self) -> PressureLevel
Returns a qualitative PressureLevel based on the current numeric pressure.
Sourcepub fn shutdown(&self)
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.
Sourcepub fn active_threads(&self) -> usize
pub fn active_threads(&self) -> usize
Returns the current number of active worker threads.
Sourcepub fn desired_threads(&self) -> usize
pub fn desired_threads(&self) -> usize
Returns the desired number of worker threads.