pub struct RepeatableSpec<T> {
pub key: String,
pub job_name: String,
pub pattern: RepeatPattern,
pub payload: T,
pub limit: Option<u64>,
pub start_after_ms: Option<u64>,
pub end_before_ms: Option<u64>,
pub missed_fires: MissedFiresPolicy,
}Expand description
A recurring job spec.
T is the payload type — same constraint as Producer<T>. Stored on
Redis as msgpack inside the {chasqui:<queue>}:repeat:spec:<key> hash
under field spec.
Catch-up after scheduler downtime is governed by
RepeatableSpec::missed_fires; see MissedFiresPolicy for the three
options. The default (MissedFiresPolicy::Skip) drops missed windows
and resumes on the first future fire — safe for any payload, no
thundering herd on restart.
Fields§
§key: StringStable identifier. Auto-derived from job_name::pattern_signature if
left empty. See module docs for the divergence from BullMQ’s hashing
scheme.
job_name: StringUser-facing job name carried into each fired Job<T>.
pattern: RepeatPatternWhat schedules the next fire time.
payload: TThe payload that every fire of this spec emits. Cloned and re-encoded per fire (the spec itself is encoded once at upsert).
limit: Option<u64>Maximum number of fires; None means unlimited. Decremented in the
same Lua tick that schedules the next fire.
start_after_ms: Option<u64>Earliest fire time in epoch milliseconds. Fires before this are skipped.
end_before_ms: Option<u64>Latest fire time in epoch milliseconds. Once next_fire_ms > end_before_ms the spec is removed from the repeat ZSET.
missed_fires: MissedFiresPolicyWhat to do with windows that elapsed while the scheduler was down.
Defaults to MissedFiresPolicy::Skip — drop missed windows and
resume on the first future fire. See MissedFiresPolicy for the
other options.
Trailing optional with skip_serializing_if so the field is omitted
from the encoded msgpack when set to the default — pre-existing
stored specs (no missed_fires field on the wire) continue to decode
unchanged into the new shape with Skip.
Implementations§
Source§impl<T> RepeatableSpec<T>
impl<T> RepeatableSpec<T>
Sourcepub fn new(
job_name: impl Into<String>,
pattern: RepeatPattern,
payload: T,
) -> Self
pub fn new( job_name: impl Into<String>, pattern: RepeatPattern, payload: T, ) -> Self
Construct a new spec with sensible defaults — the recommended
construction path going forward. Pair with the chainable
with_key /
with_limit /
with_start_after_ms /
with_end_before_ms /
with_missed_fires setters to override
individual fields.
Defaults:
key: empty (auto-derived fromjob_name::pattern_signature— seeresolved_key).limit:None(unlimited fires).start_after_ms/end_before_ms:None(no time window).missed_fires:MissedFiresPolicy::Skip(drop missed windows on scheduler restart — safe default, no thundering herd).
The struct fields remain pub for back-compat with callers that
destructure or use field-by-field literals; the constructor is an
additional path that survives future field additions without
breaking call sites.
Sourcepub fn with_key(self, key: impl Into<String>) -> Self
pub fn with_key(self, key: impl Into<String>) -> Self
Set a stable identifier for this spec. Empty (the default) means
auto-derive from job_name::pattern_signature.
Sourcepub fn with_limit(self, limit: u64) -> Self
pub fn with_limit(self, limit: u64) -> Self
Cap the total number of fires this spec emits before the scheduler removes it.
Sourcepub fn with_start_after_ms(self, ms: u64) -> Self
pub fn with_start_after_ms(self, ms: u64) -> Self
Earliest fire time in epoch ms; fires before this are skipped.
Sourcepub fn with_end_before_ms(self, ms: u64) -> Self
pub fn with_end_before_ms(self, ms: u64) -> Self
Latest fire time in epoch ms; once next_fire_ms > end_before_ms,
the scheduler removes the spec.
Sourcepub fn with_missed_fires(self, policy: MissedFiresPolicy) -> Self
pub fn with_missed_fires(self, policy: MissedFiresPolicy) -> Self
Override the catch-up policy for missed windows. See
MissedFiresPolicy.
Sourcepub fn resolved_key(&self) -> String
pub fn resolved_key(&self) -> String
Resolve the effective key for this spec, deriving a default if the user supplied an empty string.
Trait Implementations§
Source§impl<T: Clone> Clone for RepeatableSpec<T>
impl<T: Clone> Clone for RepeatableSpec<T>
Source§fn clone(&self) -> RepeatableSpec<T>
fn clone(&self) -> RepeatableSpec<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for RepeatableSpec<T>
impl<T: Debug> Debug for RepeatableSpec<T>
Source§impl<'de, T> Deserialize<'de> for RepeatableSpec<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for RepeatableSpec<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl<T> Freeze for RepeatableSpec<T>where
T: Freeze,
impl<T> RefUnwindSafe for RepeatableSpec<T>where
T: RefUnwindSafe,
impl<T> Send for RepeatableSpec<T>where
T: Send,
impl<T> Sync for RepeatableSpec<T>where
T: Sync,
impl<T> Unpin for RepeatableSpec<T>where
T: Unpin,
impl<T> UnsafeUnpin for RepeatableSpec<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for RepeatableSpec<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more