
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
@codefresh-io/cf-queue
Advanced tools
var Queue = require('cf-queue');
var options = {
servers: [
'nats://localhost:4222'
]
};
var queue = new Queue('queue-name', options);
The same initalization code is used by the clien and worker sides.
When a client would like to push request into the queue it should use the queue request function and pass the request object.
var request = {
id: 1,
message: 'hello'
}
queue.request(request)
.then(function(response) {
console.log(response);
})
.catch(function(err) {
console.error(err);
});
queue.process(function(job, callback) {
var request = job.request;
var response = {
id: request.id,
message: request.message + ' world !!!'
};
callback(null, response);
}
As first parameter for the callback you can return error message or object that will be sent back to the client as error.
When a client would like to push request into the queue it should use the queue request function and pass the request object.
var request = {
id: 1,
message: 'hello'
}
queue.request(request)
.then(function(response) {
console.log(response);
})
.progress(function(message) {
console.log('PROGRESS >>> ' + message);
})
.catch(function(err) {
console.error(err);
});
queue.process(function(job, callback) {
var request = job.request;
var response = {
id: request.id,
message: request.message + ' world !!!'
};
var counter = 0;
var sendProgress = function() {
counter++;
job.progress('Step ' + counter + ' in ' + request.id);
if (counter === 5) {
callback(null, response);
} else {
setTimeout(sendProgress, 500);
}
};
sendProgress();
}
You can see example of how to use the queue in Docker in the attached Dockerfile and docker compose file. The docker compose file load one client, two workers and the queue server.
FAQs
Queue wrapper for nats.io
The npm package @codefresh-io/cf-queue receives a total of 12 weekly downloads. As such, @codefresh-io/cf-queue popularity was classified as not popular.
We found that @codefresh-io/cf-queue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.