pub struct TaskQueue {
pub broker: Arc<RedisBroker>,
pub scheduler: Arc<TaskScheduler>,
pub autoscaler: Arc<AutoScaler>,
pub metrics: Arc<MetricsCollector>,
/* private fields */
}
Expand description
Main task queue framework
Fields§
§broker: Arc<RedisBroker>
§scheduler: Arc<TaskScheduler>
§autoscaler: Arc<AutoScaler>
§metrics: Arc<MetricsCollector>
Implementations§
Source§impl TaskQueue
impl TaskQueue
Sourcepub async fn new(redis_url: &str) -> Result<Self, TaskQueueError>
pub async fn new(redis_url: &str) -> Result<Self, TaskQueueError>
Create a new task queue instance
Sourcepub async fn with_autoscaler_config(
redis_url: &str,
autoscaler_config: AutoScalerConfig,
) -> Result<Self, TaskQueueError>
pub async fn with_autoscaler_config( redis_url: &str, autoscaler_config: AutoScalerConfig, ) -> Result<Self, TaskQueueError>
Create a new task queue with custom auto-scaler configuration
Sourcepub async fn start_workers(
&self,
initial_count: usize,
) -> Result<(), TaskQueueError>
pub async fn start_workers( &self, initial_count: usize, ) -> Result<(), TaskQueueError>
Start the specified number of workers with auto-registered tasks (if available)
Sourcepub async fn start_workers_with_registry(
&self,
initial_count: usize,
task_registry: Arc<TaskRegistry>,
) -> Result<(), TaskQueueError>
pub async fn start_workers_with_registry( &self, initial_count: usize, task_registry: Arc<TaskRegistry>, ) -> Result<(), TaskQueueError>
Start workers with a custom task registry
Sourcepub fn start_autoscaler(&self) -> Result<(), TaskQueueError>
pub fn start_autoscaler(&self) -> Result<(), TaskQueueError>
Start the auto-scaler background process
Sourcepub async fn start_scheduler(&self) -> Result<(), TaskQueueError>
pub async fn start_scheduler(&self) -> Result<(), TaskQueueError>
Start the task scheduler background process
Sourcepub async fn stop_scheduler(&self)
pub async fn stop_scheduler(&self)
Stop the task scheduler
Sourcepub async fn enqueue<T: Task>(
&self,
task: T,
queue: &str,
) -> Result<TaskId, TaskQueueError>
pub async fn enqueue<T: Task>( &self, task: T, queue: &str, ) -> Result<TaskId, TaskQueueError>
Enqueue a task for immediate execution
Sourcepub async fn schedule<T: Task>(
&self,
task: T,
queue: &str,
delay: Duration,
) -> Result<TaskId, TaskQueueError>
pub async fn schedule<T: Task>( &self, task: T, queue: &str, delay: Duration, ) -> Result<TaskId, TaskQueueError>
Schedule a task for delayed execution
Sourcepub async fn worker_count(&self) -> usize
pub async fn worker_count(&self) -> usize
Get the current number of active workers
Sourcepub async fn stop_workers(&self)
pub async fn stop_workers(&self)
Stop all workers
Sourcepub async fn shutdown(&self) -> Result<(), TaskQueueError>
pub async fn shutdown(&self) -> Result<(), TaskQueueError>
Initiate graceful shutdown of the entire task queue
Sourcepub async fn shutdown_with_timeout(
&self,
timeout: Duration,
) -> Result<(), TaskQueueError>
pub async fn shutdown_with_timeout( &self, timeout: Duration, ) -> Result<(), TaskQueueError>
Shutdown with a custom timeout
Sourcepub async fn is_shutting_down(&self) -> bool
pub async fn is_shutting_down(&self) -> bool
Check if shutdown has been initiated
Sourcepub async fn shutdown_receiver(&self) -> Option<Receiver<()>>
pub async fn shutdown_receiver(&self) -> Option<Receiver<()>>
Get a shutdown signal receiver for external components
Sourcepub async fn health_check(&self) -> Result<HealthStatus, TaskQueueError>
pub async fn health_check(&self) -> Result<HealthStatus, TaskQueueError>
Get comprehensive health status
Sourcepub async fn get_metrics(&self) -> Result<TaskQueueMetrics, TaskQueueError>
pub async fn get_metrics(&self) -> Result<TaskQueueMetrics, TaskQueueError>
Get comprehensive metrics
Sourcepub async fn get_system_metrics(&self) -> SystemMetrics
pub async fn get_system_metrics(&self) -> SystemMetrics
Get enhanced system metrics with memory and performance data
Sourcepub async fn get_metrics_summary(&self) -> String
pub async fn get_metrics_summary(&self) -> String
Get a quick metrics summary for debugging