![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
hique is a job queue for NodeJS.
feel free to contribute / open issues / create pull requests / fork
hique is heavily inspired by kue and bee-queue, and after using both frameworks pretty extensively I found that, though very well written, these frameworks do not fulfill two of my most desired aspects in:
hique was designed with these in mind.
hique differs from most frameworks by sacrificing a bit of performance to gain a much more stable environment, even when scaled up on different machines.
To scale hique to available cpus / machines, simply create a NodeJS process with a hique worker pointing to the same monitor object as every other worker and voila! scaling done easy.
npm install hique
npm install git+https://github.com/patriceperez/hique.git
Here is a simple example on how to set up a basic worker and a few jobs for testing
var hq = require('../lib/hique');
var monitor = new hq.Monitor();
var worker = new hq.Worker();
monitor.start();
worker.process('testJob', 5, function (job, done) {
console.log('executed job %s with data %s', job.id, JSON.stringify(job.data));
job.reportProgress(1, 1);
done(null, job.data.test);
});
for (var i = 0; i < 13; i++) {
worker.createJob('testJob', {test: i}, function (job) {
console.log('save new job %s and data %s', job.id, JSON.stringify(job.data));
});
}
worker.start();
check out the examples folder for more use cases
Default configuration for workers
{
job: {
ttl: 5 * 60 * 1000
},
cleanUp: {
active: true,
refreshRate: 5 * 60 * 1000
},
refreshRate: 1000,
monitor: {
host: 'http://127.0.0.1',
port: '3001'
}
}
Any value can be overridden by providing a new value via the worker constructor:
new Worker({refreshRate: 2000})
Field | Description |
---|---|
job.ttl | maximum time allowed (in milliseconds) for a job to stay active |
cleanUp.active | should the cleanup process remove outdated data from the data store |
cleanUp.refreshRate | interval (in milliseconds) between cleanup iterations |
refreshRate | interval (in milliseconds) between job updates fetching in the data store |
monitor.host | the host of the coordinating data store |
monitor.port | the port the data store is listening on |
Process a new job type
worker.process(type, concurrency, function(job, done){
// job logic
done(error, result);
});
param | Description |
---|---|
type | string literal representing the job type |
concurrency (optional) | integer representing the amount of concurrent jobs the worker can handle simultaneously |
Create a new job
worker.createJob(type, data, function(job){
//job object contains the job id as well as other meta data
});
param | Description |
---|---|
type | string literal representing the job type |
data | JSON object providing data to the job execution function |
Pause the worker from handling any new work
worker.pause();
Resume the worker to handle any new work
worker.start();
Get an existing job from redis with its current state
worker.getJob(type, id, function(job){
//job object contains the job status as well as other meta data
});
param | Description |
---|---|
type | string literal represnting the job type |
id | integer representing the job id |
Get a completed job's result
worker.getJobResult(type, id, function(result){
// handle result of the job
});
param | Description |
---|---|
type | string literal representing the job type |
id | integer representing the job id |
Get an overview of each job type and its status (active, pending, etc...)
worker.getStats(function(stats){
// handle system wide stats
});
Job functions are available within the processing function, and can be used freely inside a worker.process()
function
Report and save the current progress of the job
job.reportProgress(step, total);
param | Description |
---|---|
step | integer representing the current step progress from the total |
total | integer representing the total amount of progress steps in the job |
example: job.reportProgress(5,10)
will result in 50% progress for the job
Add a child job to the current job
job.addChild(job);
param | Description |
---|---|
job | a live Job object, usually gathered from a worker.getJob() or worker.createJob() functions |
Gather data from child jobs, previously added via job.addChild()
job.waitForChildren(function(){
// handle data from children
});
done()
can be called inside the job.waitForChildren()
callbacAfter cloning the repo and resolving dependencies via npm install
, run
npm test
hique saves all data in-memory by default. (using the 'native' adapter)
Data is stored inside the data store through an adapter
object, which is highly extensible, allowing adapters be written for other data stores (mysql, mongo, redis, etc`) fairly easily
The native adapter saves all data in-memory in the javascript's heap. Since the heap is limited to about 1.2G by default (per process) it can be switched to any other adapter.
In order to create your own data store please follow these simple steps:
lib/adapters
directorystub.js
in order to get the interface of all adaptersnative.js
for more details about how to invoke the correct data in callbacks)config/default.js
under the adapter
key to be passed at initialization, this will allow to pass a config object at runtime for specific hosts, ports, etc`FAQs
job queue for nodejs
We found that hique 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.