Files
mytheclipse/crates/mytheclipse-queue
asepharyana 1dfc6d6865 fix(ci): restore full CI green — test-matrix, clippy, rustfmt, and rustdoc gates
Root cause of the failing CI run was that examples/tests referencing
feature-gated items were auto-detected (no required-features), so
`--all-targets` compiled them under feature combinations where those
modules didn't exist. Fixes:

- mytheclipse Cargo.toml: declare the `high_level` example and
  `race_stress` integration test with required-features = ["full"];
  `cargo build --all-targets` now skips them when full is off. This
  clears the whole test-matrix (workspace default, all-features, and
  every single-feature config) which all failed on E0432/E0433.
- lib.rs: auto_metrics_service depends on service_builder, so regate it
  behind all(observability, resiliency) instead of observability alone
  (observability-only build compiled the module without resiliency).
- mytheclipse-tracing: gate `pub mod fmt` behind any
  tracing-subscriber-providing feature so --no-default-features compiles.
- mytheclipse-queue: gate `pub mod worker` behind in-memory (worker.rs
  requires tokio, only provided by in-memory).
- clippy -D warnings fixes: deprecated base64 0.22 free fns -> Engine
  (paseto), unused key field, needless mut (service_builder), unused
  import/dead var/missing is_empty (bg_join), dead is_expired (dlock),
  while-let-iterator->for (parallel_map), type_complexity (shutdown_guard),
  MutexGuard held across await (middleware, now clones Arc'd layers),
  if-let-Err->is_err (queue), unused CliBuilder fields now wired into clap.
- rustdoc -D warnings: resolve retry/MetricsBridge/CircuitBreaker/KeyRing
  intra-doc links and fix the unparseable lifecycle.rs code fence.
- cargo fmt --all to satisfy the Rustfmt gate.
2026-08-30 00:33:21 +07:00
..
2026-08-29 17:00:18 +00:00

mytheclipse-queue

A unified job queue abstraction so your background work isn't locked to one transport. Provides a single Queue trait, Job type, and WorkerPool executor with configurable retry/backoff, concurrency, and a dead-letter queue — behind pluggable backends:

  • In-memory (default) — tokio::sync::mpsc + task spawning, no external service.
  • Redis (redis) — LIST-based queue with atomic moves.
  • NATS JetStream (nats) — durable consumer with ACK/NACK.
  • PostgreSQL (postgres) — SKIP LOCKED polling.

All backends share the same WorkerPool driver; swapping is a one-line change at construction time.

Features

Feature Default Backend Description
in-memory yes tokio::sync In-process queue, no external deps.
redis no redis crate (fred) Redis/Valkey list-based queue.
nats no async-nats NATS JetStream durable consumer.
postgres no tokio-postgres PostgreSQL SKIP LOCKED queue.

Usage

use mytheclipse_queue::{InMemoryQueue, WorkerPool, Job, JobHandler, JobFuture};

fn print_handler() -> impl JobHandler {
    struct PrintHandler;
    impl JobHandler for PrintHandler {
        fn handle(&self, job: Job) -> JobFuture {
            Box::pin(async move {
                println!("payload: {:?}", job.payload);
                Ok(())
            })
        }
    }
    PrintHandler
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let queue = InMemoryQueue::new();
    queue.enqueue("email", b"hello".to_vec()).await?;

    let pool = WorkerPool::new(queue, 4);
    pool.start("email", print_handler());

    Ok(())
}

Swap InMemoryQueue::new() for RedisQueue::connect("redis://127.0.0.1") (with the redis feature) or NatsQueue::connect("nats://127.0.0.1") (with the nats feature) to move to a distributed broker without touching handler code.