Giter Site home page Giter Site logo

jasonjayr / node-maildir-queue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from munogu/node-maildir-queue

0.0 0.0 0.0 48 KB

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

Home Page: https://munogu.com

License: MIT License

JavaScript 100.00%

node-maildir-queue's Introduction

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.

node-maildir-queue's People

Contributors

eymengunay avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.