reliar-store-postgres 0.9.0

PostgreSQL provider for the Reliar transactional outbox and inbox: migrations, migrate(), enqueue and the SKIP LOCKED claim.
Documentation
use std::future::Future;
use std::time::Duration;

/// Polls `f` every 20ms until it resolves `true` or `timeout` elapses, panicking on timeout — the
/// bounded, non-flaky alternative to a blind sleep for a condition driven by a real background
/// task or by another connection's transaction (ADR 0043 §5's *eventually* rule). Promoted here
/// from four byte-identical local copies (the former `outbox_dispatcher_end_to_end.rs`, now
/// folded into `outbox_dispatcher_lifecycle.rs`, `inbox_claim.rs`,
/// `inbox_purge.rs`, `outbox_purge_concurrent_resurrection.rs`). `what` names the condition being
/// waited for, so a timeout failure reads as *what* never became true rather than only *how long*
/// it was waited for.
pub(crate) async fn wait_until<F, Fut>(what: &str, timeout: Duration, mut f: F)
where
    F: FnMut() -> Fut,
    Fut: Future<Output = bool>,
{
    let deadline = tokio::time::Instant::now() + timeout;

    loop {
        if f().await {
            return;
        }

        assert!(
            tokio::time::Instant::now() < deadline,
            "{what} not met within {timeout:?}"
        );

        tokio::time::sleep(Duration::from_millis(20)).await;
    }
}