Skip to content

munogu/node-maildir-queue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maildir queue Build Status Coverage Status

File system backed lock-free and atomic message queue for Node.js. Stores messages using Maildir format to avoid using file locks.

Standard - JavaScript Style Guide

Requirements

Installation

$ npm install @munogu/maildir-queue

Quick Start

// module dependencies
const Queue = require('@munogu/maildir-queue')

// initialize queue
let queue = new Queue('your_queue_name')

Usage

// module dependencies
const Queue = require('@munogu/maildir-queue')

// queue options
let options = {
  // output directory
  dir: '/path/to/output/directory',
  // time to live in milliseconds
  ttl: 86400 * 1000,
  // max retries, -1 for infinite, 0 for no retries
  retries: 10
}

// initialize queue
let queue = new Queue('your_queue_name', options)

// add new item to queue
queue.add({
  foo: 'bar'
})

// pop item from queue
queue.pop(item => {
  console.log('item id %s', item.id)
})

API

add(payload = object) - Promise

queue.add({
  this: 'is',
  the: 'payload object'
})

pop(handler = function) - Promise

queue.pop(item => {
  console.log('received item with id %s', item.id)
})

count() - Promise

Returns total count of items in the queue.

queue.count().then(count => {
  console.log('%s item(s) found', count)
})

empty() - Promise

Deletes all expired items according to ttl setting.

queue.empty().then(() => {
  console.log('queue emptied successfully!')
})

Debugging

Maildir queue along with many of the libraries it's built with support the DEBUG environment variable from debug which provides simple conditional logging.

For example to see all maildir-queue specific debugging information just pass DEBUG=queue* and upon boot you'll see the list of middleware used, among other things.

About

File system backed lock-free message queue for Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published