Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

child-queue

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

child-queue

Creates child processes to handle a queue of inputs

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Node Child Queue

Allow complex tasks to be queued and processed by child processes to speed up your Node application.

Examples

main.js

var Queue = require("child-queue");
var queue = new Queue(require.resolve("./child"));
queue.request({type: "weather", area: "New York"}, function(err, result) {
    if (err) {
        throw err;
    }
    console.log("The weather in New York is " + result.toLowerCase());
    queue.close(true);
});

child.js

var http = require("http");
module.exports = function(input, callback) {
    if (input.type == "weather") {
        http.get('http://api.openweathermap.org/data/2.5/weather?q=' + input.area, function(res) {
            var body = '';

            res.on('data', function(chunk) {
                body += chunk;
            });

            res.on('end', function() {
                try {
                    callback(undefined, JSON.parse(body).weather[0].main);
                } catch (err) {
                    callback(err);
                }
            });
        }).on('error', function(e) {
            callback(e);
        });
    }
};

API

The included API is quite simple to understand

new Queue([options, ]pathToChild)

Creates a new queue to handle processes. The pathToChild should be relative.

options

If you don't supply an options object, the following will be used

{
    maxProcesses: 5,
    preLoadChildren: false,
    allowOverflow: true
}
  • maxProcesses the most child processes you want running at a single time
  • preLoadChildren when set, the child processes will be created before giving an input
  • allowOverflow allows you to give an input even when all processes are busy. It will be inputted whenever a process is ready

Keywords

FAQs

Package last updated on 05 Jan 2015

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc