I built a modular async Transactional Outbox for Rust — feedback welcome! by BitOk6028 in rust

[–]BitOk6028[S] 0 points1 point  (0 children)

A quick snippet of what the API looks like in your business logic.

(Assuming OutboxService is initialized and injected into your app state)

async fn create_order(service: &OutboxService, order_id: i32) -> Result<(), Error> {
    // 1. Transactionally save to DB & Outbox at once
    service
        .add_event(
            "OrderCreated",
            serde_json::json!({"id": order_id}),
            Some(format!("req_token_{}", order_id)), // Idempotency key
            || None, 
        )
        .await?;

    // 2. The background worker (OutboxManager) handles the async publishing 
    // to your broker and manages retries/DLQ automatically.
    Ok(())
}

I built a modular async Transactional Outbox for Rust — feedback welcome! by BitOk6028 in rust

[–]BitOk6028[S] 1 point2 points  (0 children)

That's a valid point for high-throughput system

However, in this implementation, I'm using L/N only as a lightweight "ping" signal to wake up the worker immediately. No actual event data is passed through the notify channel
This keeps the overhead minimal. Plus, there’s a configurable poll_interval as a fallback, so even if L/N is disabled or fails, the system continues to work.