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

query-swarm

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

query-swarm - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

.travis.yml

5

lib/QuerySwarm.js

@@ -83,2 +83,3 @@ 'use strict';

self.active = true;
return self;
};

@@ -95,2 +96,4 @@

});
return self;
};

@@ -103,2 +106,3 @@

});
return self;
};

@@ -182,2 +186,3 @@

});
return self;
};

@@ -184,0 +189,0 @@

9

package.json
{
"name": "query-swarm",
"version": "0.0.1",
"version": "0.0.2",
"description": "Safely distribute query-driven tasks over a swarm of parallel functions on a single process or across multiple processes/machines.",
"keywords": "schedule, queue, task, job, worker, redis, distributed, async",
"author": "Mike Marcacci <mike.marcacci@thecontrolgroup.com>",

@@ -29,3 +30,4 @@ "contributors": [

"dependencies": {
"async": "^0.9.0"
"async": "^0.9.0",
"redis": "^0.11.0"
},

@@ -35,5 +37,4 @@ "devDependencies": {

"mocha": "^1.21.0",
"redis": "^0.11.0",
"redis-mock": "^0.3.0"
"redis": "^0.11.0"
}
}

@@ -6,2 +6,40 @@ Query Swarm

tl;dr
-----
```js
var redis = require('redis').createClient();
var QuerySwarm = require('../lib/QuerySwarm.js')(redis);
function query(cursor, callback) {
// you can get a starting cursor from another data source if you wish
cursor = cursor || 0;
// perform the query (you would probably connect to a database here...)
var results = [], newCursor = cursor;
while (newCursor < cursor + 100) {
results.push(newCursor);
newCursor++;
}
// return any error, the new cursor, and results
callback(null, newCursor, results);
}
function worker(task, callback) {
// do something with the task
var result = task * 2;
// return any error, and the result
callback(null, result);
}
var swarm = new QuerySwarm('myFirstSwarm', query, worker);
swarm.start();
swarm.stop(function(){
// this node has gracefully stopped
});
```
####Use when the following are important:

@@ -8,0 +46,0 @@ - Tasks should be allowed a long time to complete

Sorry, the diff of this file is not supported yet

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