pub struct SchedulerBuilder { /* private fields */ }
Expand description
Builder for configuring and creating a TurnKeeper
scheduler instance.
Provides methods to set essential parameters like worker count and the underlying scheduling mechanism.
§Example
use turnkeeper::{TurnKeeper, scheduler::PriorityQueueType};
let scheduler = TurnKeeper::builder()
.max_workers(4)
.priority_queue(PriorityQueueType::HandleBased)
.staging_buffer_size(256) // Optional: configure buffer size
.build()?;
Implementations§
Source§impl SchedulerBuilder
impl SchedulerBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new builder with default settings.
max_workers
: Not set (required).priority_queue
:HandleBased
.- Buffer sizes: Default constants.
Sourcepub fn max_workers(self, count: usize) -> Self
pub fn max_workers(self, count: usize) -> Self
Sets the maximum number of jobs that can run concurrently (required). Must be greater than 0 for jobs to execute.
Sourcepub fn priority_queue(self, pq_type: PriorityQueueType) -> Self
pub fn priority_queue(self, pq_type: PriorityQueueType) -> Self
Sets the type of priority queue to use for scheduling.
See PriorityQueueType
documentation for implications.
Sourcepub fn staging_buffer_size(self, size: usize) -> Self
pub fn staging_buffer_size(self, size: usize) -> Self
Sets the size of the internal buffer for staging newly added jobs. A larger buffer can handle larger bursts of submissions but uses more memory.
Sourcepub fn command_buffer_size(self, size: usize) -> Self
pub fn command_buffer_size(self, size: usize) -> Self
Sets the size of the internal buffer for commands (queries, cancellations).
Sourcepub fn job_dispatch_buffer_size(self, size: usize) -> Self
pub fn job_dispatch_buffer_size(self, size: usize) -> Self
Sets the size of the internal channel used to dispatch job IDs to idle workers. A size of 1 (default) means the coordinator waits if no worker immediately picks up the job, providing backpressure. Larger sizes may increase throughput slightly but reduce backpressure visibility.
Sourcepub fn build(self) -> Result<TurnKeeper, BuildError>
pub fn build(self) -> Result<TurnKeeper, BuildError>
Builds and starts the TurnKeeper
scheduler.
This spawns the central Coordinator task and the pool of Worker tasks.
§Errors
Returns Err(BuildError::MissingMaxWorkers)
if max_workers
was not set.