Skip to content

A fixed-size queue which regrets throwing away stale data

Notifications You must be signed in to change notification settings

tureus/rue-queue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RueQueue

A fixed-size queue with callback invocation. If the callback fails it backs off for a fixed amount of time. Evicts the oldest data when the queue is full, it also keeps track of the number of evictions.

Usage:

var rq = new RueQueue({
  name: "my-cool-ruequeue",
  maxsize: 10,
  retryWait: 1000, // 1 second
  callback: function(value,queueHandle){
    console.log("going to drain: ", value);
    var success;
    // do something
    if success {
      queueHandle.success();
    } else {
      queueHandle.error();
    }
  }
});

// Elsewhere in your code...
rq.push({my: "datum", is: "cool"});

// stdout will print:
// going to drain: {my: "datum", is: "cool"}

// But if the queue starts to overflow you will get a special datum:
// {_regrets: 15}

About

A fixed-size queue which regrets throwing away stale data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published