query-swarm
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -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 @@ |
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
20030
3
539
73
0
2
8
+ Addedredis@^0.11.0
+ Addedredis@0.11.0(transitive)