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

parallel_machine

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parallel_machine

Javascript library for distributing tasks over many keys, limiting parallelism for each.

  • 0.3.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

parallel_machine

Build Status NPM version

Javascript library for distributing async computation based on a distribution key.

Installation

npm install parallel_machine

Example

Scenario: We want to run multiple expensive database migrations across many tables in a large database cluster.

We try to distribute the load across all the database hosts via parallel_machine. This will both minimize the operation time as we'll be doing multiple operations at once whilst avoiding overloading a single host.

var parallel_machine = require("parallel_machine");

tables = [
  {databaseHost: 'a', tableName: 'foo'}
  // ...
]

function expensiveDatabaseMigration(task, callback) {
  // ...
}

var options = {
  // Key which we distribute over - in this case the host of the task we're about to run.
  taskDescriptor: (task) => task.databaseHost,
  // Async function that executes the given task.
  executor: expensiveDatabaseMigration,
  // (Up to) how many tasks to execute on a host at a time in parallel.
  keyParallelism: 5,
  // How many tasks to execute overall in parallel. Missing or null means unlimited.
  overallParallelism: 30
}

parallel_machine(tables, options, (err) => {
  console.log('Tasks complete.', err);
});

Keywords

FAQs

Package last updated on 06 Jan 2017

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