Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
assemblage is a super simple module to create distributed clusters of worker processes with one or more master.
Master process has an interface to add and remove jobs. Worker processes check in for new jobs and emit information about new jobs received or removed. If master goes down, no new jobs can be added but workers continue working with current jobs unaffected. When a worker goes down, master reassigns all the jobs of the worker to other workers.
All the synchronization between master and workers is done with the help of Redis.
This application works only on Redis with versions higher than 2.6.12 You can got actual versions on this page http://redis.io/download
Master shares jobs between clients.
Create master with
assemblage.createMaster(clusterId, redisConfig)
where
"localhost"
)6379
)0
)Example
var assemblage = require("assemblage");
var master = assemblage.createMaster("my-cluster", {host: "localhost"});
To add a new job, simply call
master.addJob(data, callback)
Where
master.addJob({key: "value"}, function(err, jobId){
console.log("Added new job with ID: %s", jobId);
});
To remove previously registered job, simply call
master.deleteJob(jobId, callback)
Where
addJob
)master.deleteJob("12345", function(err, jobId){
console.log("Deleted job with ID: %s", jobId);
});
Worker receives jobs queued by the master.
Create a worker with
assemblage.createWorker(clusterId, redisConfig)
where
"localhost"
)6379
)0
)Example
var assemblage = require("assemblage");
var worker = assemblage.createWorker("my-cluster", {host: "localhost"});
Worker can listen for new jobs with "add"
event. The event has one parameter - job object.
worker.on("add", function(job){
console.log("Received new job %s", job.id);
console.log(job.payload);
});
Job removals with can be listened with "delete"
events on the job object. Whatever this job was doing when a "delete"
event is received, should be terminated. "delete"
is emitted only once, so no need to use on()
method to listen for it, use once()
instead.
job.once("delete", function(){
console.log("Remove job %s", job.id);
});
You can remove a job in the worker as well with using job.deleteJob(callback)
- this doesn't actually remove the job, but queues it for deletion.
A worker can be closed and all jobs released for reassignment to other workers with terminate(callback)
worker.terminate();
For all jobs a "delete"
event is emitted as well when terminating
Terminating a worker (either by terminate
method or forced by the expired lock) also emits "close"
event.
worker.on("close", function(){
console.log("The worker was closed, no new jobs for this one");
});
On unexpected errors an "error"
event is thrown.
Install vows and test as usual
$ npm install vows
$ npm test
FAQs
Manage master + workers with the help of Redis
The npm package assemblage receives a total of 1 weekly downloads. As such, assemblage popularity was classified as not popular.
We found that assemblage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.