Skip to main content

RepeatableSpec

Struct RepeatableSpec 

Source
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: String

Stable identifier. Auto-derived from job_name::pattern_signature if left empty. See module docs for the divergence from BullMQ’s hashing scheme.

§job_name: String

User-facing job name carried into each fired Job<T>.

§pattern: RepeatPattern

What schedules the next fire time.

§payload: T

The 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: MissedFiresPolicy

What 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>

Source

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 from job_name::pattern_signature — see resolved_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.

Source

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.

Source

pub fn with_limit(self, limit: u64) -> Self

Cap the total number of fires this spec emits before the scheduler removes it.

Source

pub fn with_start_after_ms(self, ms: u64) -> Self

Earliest fire time in epoch ms; fires before this are skipped.

Source

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.

Source

pub fn with_missed_fires(self, policy: MissedFiresPolicy) -> Self

Override the catch-up policy for missed windows. See MissedFiresPolicy.

Source

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>

Source§

fn clone(&self) -> RepeatableSpec<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for RepeatableSpec<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Serialize for RepeatableSpec<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,