🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More →
Socket
Book a DemoInstallSign in
Socket

lokue

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lokue

LokiJS Task Queue

latest
Source
npmnpm
Version
0.0.9
Version published
Maintainers
4
Created
Source

lokue: LokiJS Job Queue

Simple LokiJS Job Queue management

Features

  • Persist to file
  • Fast (configurable concurrency)
  • Small library

Example

const Lokue = require('lokue')

const lok = new Lokue({
  name: 'lokue-test.json',
  persist: true,
  concurrency: 10,
  timeout_save: 50,
  timeout_save: 100
})

lok.init((err) => {
  let ix = 0

  setInterval(() => {
    ix++
    lok.addJob({ hello: 'world' + ix })
  }, 100)
})

lok.on('job', job => {
  console.log('processing', job.data)
  job.done()
})

setInterval(() => {
  if (lok.isReady()) {
    lok.requeueStuckJobs()
    lok.clearCompletedJobs()
  }
}, 1000)

process.on('SIGINT', () => {
  if (lok.isReady()) {
    lok.stop(() => {
      console.log('saved')
      process.exit()
    }) 
  } else {
    process.exit()
  }
})

Contributors

Keywords

bitfinex

FAQs

Package last updated on 08 Aug 2024

Did you know?

Socket

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