Skip to main content

Crate a3s_lane

Crate a3s_lane 

Source
Expand description

§A3S Lane

A priority-based command queue for async task scheduling.

§Core (always compiled)

  • Priority-based scheduling with per-lane concurrency control
  • Command timeout and retry policies (exponential backoff, fixed delay)
  • Dead letter queue for permanently failed commands
  • Persistent storage (pluggable Storage trait, LocalStorage included)
  • Event system for queue lifecycle notifications
  • Graceful shutdown with drain support

§Feature Flags

FeatureDefaultDependenciesDescription
metricsMetricsBackend trait, LocalMetrics, latency histograms
monitoringmetricsAlertManager, QueueMonitor with depth/latency thresholds
telemetryopentelemetry, dashmapOpenTelemetry spans and OtelMetricsBackend
distributednum_cpusPartitioning, rate limiting, priority boosting, DistributedQueue

§Quick Start

use a3s_lane::{QueueManagerBuilder, EventEmitter, Command, Result};
use async_trait::async_trait;

struct MyCommand { data: String }

#[async_trait]
impl Command for MyCommand {
    async fn execute(&self) -> Result<serde_json::Value> {
        Ok(serde_json::json!({"processed": self.data}))
    }
    fn command_type(&self) -> &str { "my_command" }
}

#[tokio::main]
async fn main() -> Result<()> {
    let manager = QueueManagerBuilder::new(EventEmitter::new(100))
        .with_default_lanes()
        .build()
        .await?;

    manager.start().await?;

    let rx = manager.submit("query", Box::new(MyCommand { data: "hello".into() })).await?;
    let result = rx.await??;
    println!("Result: {}", result);
    Ok(())
}

Re-exports§

pub use config::LaneConfig;
pub use dlq::DeadLetter;
pub use dlq::DeadLetterQueue;
pub use error::LaneError;
pub use error::Result;
pub use event::EventEmitter;
pub use event::EventPayload;
pub use event::EventStream;
pub use event::LaneEvent;
pub use manager::QueueManager;
pub use manager::QueueManagerBuilder;
pub use queue::lane_ids;
pub use queue::priorities;
pub use queue::Command;
pub use queue::CommandId;
pub use queue::CommandQueue;
pub use queue::JsonCommand;
pub use queue::Lane;
pub use queue::LaneId;
pub use queue::LaneStatus;
pub use queue::Priority;
pub use retry::RetryPolicy;
pub use storage::LocalStorage;
pub use storage::Storage;
pub use storage::StoredCommand;
pub use storage::StoredDeadLetter;
pub use alerts::Alert;
pub use alerts::AlertLevel;
pub use alerts::AlertManager;
pub use alerts::LatencyAlertConfig;
pub use alerts::QueueDepthAlertConfig;
pub use boost::PriorityBoostConfig;
pub use boost::PriorityBooster;
pub use distributed::CommandEnvelope;
pub use distributed::CommandResult;
pub use distributed::DistributedQueue;
pub use distributed::LocalDistributedQueue;
pub use distributed::WorkerId;
pub use distributed::WorkerPool;
pub use metrics::metric_names;
pub use metrics::HistogramPercentiles;
pub use metrics::HistogramStats;
pub use metrics::LocalMetrics;
pub use metrics::MetricsBackend;
pub use metrics::MetricsSnapshot;
pub use metrics::QueueMetrics;
pub use monitor::MonitorConfig;
pub use monitor::QueueMonitor;
pub use partition::CustomPartitioner;
pub use partition::HashPartitioner;
pub use partition::PartitionConfig;
pub use partition::PartitionId;
pub use partition::PartitionStrategy;
pub use partition::Partitioner;
pub use partition::RoundRobinPartitioner;
pub use ratelimit::RateLimitConfig;
pub use ratelimit::RateLimiter;
pub use ratelimit::SlidingWindowLimiter;
pub use ratelimit::TokenBucketLimiter;
pub use telemetry::OtelMetricsBackend;

Modules§

alerts
Alert system for queue monitoring and notifications.
boost
Priority boosting for deadline-based priority adjustment
config
Lane configuration types
distributed
Distributed queue support for multi-machine parallel processing
dlq
Dead Letter Queue for permanently failed commands
error
Error types for the lane queue system
event
Event system for queue notifications
manager
Queue manager provides high-level queue management
metrics
Metrics collection and reporting for queue observability.
monitor
Queue monitor for tracking queue metrics and health
partition
Queue partitioning for parallel processing
queue
Core queue implementation with lanes and priority scheduling
ratelimit
Rate limiting for lanes
retry
Retry policy for failed commands
storage
Persistent storage for queue state
telemetry
OpenTelemetry telemetry for the A3S Lane command queue.

Structs§

QueueStats
Queue statistics snapshot