Socket
Socket
Sign inDemoInstall

unique-kue

Package Overview
Dependencies
4
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    unique-kue

plugin for kue, to enable unique delayed job


Version published
Weekly downloads
36
increased by157.14%
Maintainers
1
Install size
302 kB
Created
Weekly downloads
 

Readme

Source

unique-kue

you want your delayed jobs to run only once even if they are triggered several time during a fixed delay? Then you need unique-kue.

unique-kue is a kue plugin that adds a new method to kue: jobs.create_unique_delayed(type, key, delay, options)

install

npm install unique-kue

setup

kue = require('kue');
unique_kue = require('unique-kue');
unique_kue.setup(kue);

use

create a unique job

jobs = kue.createQueue();
jobs.create_unique_delayed('email_summary', 'email-summary-project-123456', 60000, {
    title: 'project dashboard'
  , to: 'martin@saintmac.me'
  , template: 'this week progress...'
});
//the job will be saved automatically

setTimeout(function() {
    jobs.create_unique_delayed('email_summary', 'email-summary-project-123456', 60000, {
        title: 'project dashboard'
      , to: 'martin@saintmac.me'
      , template: 'this week progress...'
    });
}, 40000); //creating the same job, 40s later (with a 60s) delay
//only the second job will be run

delete a unique job

If you don't want a delayed job to run, you can delete it using the same key you used to create it:

jobs.delete_unique('email-summary-project-123456');

Keywords

FAQs

Last updated on 06 Dec 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc