queuey-macros 0.2.1

Derive macros (#[derive(Queues)], #[derive(Job)]) for queuey
Documentation

Derive macros for queuey.

  • [macro@Queues] implements queuey_core::QueueSet for a fieldless enum.
  • [macro@Job] implements queuey_core::Job for a serializable payload type.

Where the generated code points

Generated code needs a path to queuey-core. Both macros work that out from the calling crate's Cargo.toml (via proc-macro-crate):

  1. a dependency on queuey (the facade), which emits ::queuey::__core, its hidden re-export of the core crate;
  2. otherwise a dependency on queuey-core, which emits ::queuey_core;
  3. otherwise it falls back to ::queuey_core.

Renamed dependencies (aq = { package = "queuey" }) are handled. For anything else (a vendored copy, a re-export under yet another name) say so explicitly with #[queues(crate = "...")] / #[job(crate = "...")], which always wins.

Duration literals

Every duration in these attributes is a string literal parsed while the macro runs: an integer followed by an optional unit of ms, s, m, h or d. A bare integer means seconds. Whitespace is ignored, so "500ms", "30s", "2 m" and "30" are all valid. Anything else is a compile error pointing at the literal. Zero is rejected everywhere a duration is accepted: a zero message_ttl discards every message on publish, and a zero backoff is spelled backoff = "none".

retry(...) grammar

Shared by #[queue(...)] and #[job(...)]:

retry(
    max_attempts = 3,            // u32 >= 1, default 3 (1 means no retries)
    backoff = "exponential",     // "none" | "fixed" | "exponential", default "exponential"
    delay = "1s",                // fixed only, required for "fixed"
    base = "1s",                 // exponential only, default "1s", must be <= max
    factor = 2.0,                // exponential only, default 2.0, must be > 0
    max = "5m",                  // exponential only, default "5m"
    jitter = true,               // exponential only, default true
)

The exponential defaults match queuey_core::Backoff::exponential().