Skip to content

Find if there is a pending instance of a given job #58

Open
@yched

Description

@yched

For a couple use cases (detailed below), I would need to find if there exists pending instances of a given job.

Unless I'm missing something, it seems the current API offers no way of doing that ? (aside from using internal methods or querying the jobs collection directly, which might break on subsequent package versions)

My use cases :

  • Setting up "cron tasks" on startup :
    With the new features in 3.0 I can have jobs that reschedule (well, replicate()) themselves at a later date after completion.
    On app startup I register the callbacks, and then need to schedule the 1st run - but only if there is no pending run already scheduled from a previous startup
    (Think of a deploy that adds a new cron task that didn't exist before)

  • Debouncing execution of a task between web backends :
    We host our app on several (well, 2 at the moment) servers behind HAProxy.
    There are some expensive tasks, triggered by user frontend action received by DDP method, or by external services through an HTTP route, that we would like to debounce. That debounce needs to cover calls triggered by any of the servers.
    I was thinking of doing that by scheduling a job for execution a couple seconds later - but only if an instance isn't already pending.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions