npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fatusjs

v0.6.1

Published

Job Queue Manager based on Azure Storage

Downloads

8

Readme

fatusjs

Azure queue based job queue for nodejs. Simple and lightweight.

Installation

The easiest installation is through NPM:

npm install fatusjs

Or clone the repo https://github.com/auridevil/fatusjs and include the ./fatus script.

API

Initialize:

var Fatusjs = require('fatusjs');
var fatusQueue = Fatusjs.instance;
// fatus is single istance, any call
// of Fatusjs.instance return the same obj
fatusQueue.addWorker();

Add a new worker:

fatusQueue.addWorker();

Add a new simple job to the queue:

// create the object
var msgObjSimple = {
    module   : '/test/simplefunction', // module to require
    function : 'invoke', // function to invoke, in the module
    payload  : {
        // all the data needed by the function
        mydata : 'hello',
        who    : 'world',
        arr    : [1,2,3,4,5,6,7,8,9],
        obj    : {
            inner : true,
            desc  : 'inner object'
        }
    },
    isSimple: true
};

// convert to msg
var jobObj = fatusQueue.createMessageJob();
jobObj.setSimpleJob(msgObjSimple.module,msgObjSimple.function,msgObjSimple.payload,0,[]);
var msgJson = jobObj.getMsg();

// add to the queue
fatusQueue.insertInQueue(msgJson,function onComplete(err,res){
        assert.equal(err,null);
        ...
})

Add a new multistep job to the queue:

// crete the objects
var step1Obj = { module: '/test/mymodule', function : 'foo' }
var step2Obj = { module: '/test/mymodule', function : 'bar' }
var step3Obj = { module: '/test/lib/mymodule', function : 'foo' }
var payload  = { } // payload can be empty or whatever

// create the job
var msgJob = fatusQueue.createMessageJob();
msgJob.setMultiJob();

// add steps
msgJob.addStep(stepObj1.module,stepObj1.function,payload);
msgJob.addStep(stepObj2.module,stepObj2.function);
msgJob.addStep(stepObj3.module,stepObj3.function);

// add to queue
fatusQueue.insertInQueue(msgJob.getMsg(),function onComplete(err,res){
     assert.equal(err,null);
     ...
})

Configure

In order to work there are some mandatory configurations, all at enviroment level:

AZURE_STORAGE_ACCOUNT: account name of the azure storage account

AZURE_STORAGE_ACCESS_KEY: access key of the azure storage account

CLOUD_STORAGE_ACCOUNT: connection string for the azure storage account

The others configurations is not mandatory:

FATUS_QUEUE_NAME: name of the queue to be created for the fatus

FATUS_QUEUE_FAIL_NAME: name of the queue to be crated for the fatus worker failed

FATUS_MAX_WORKER: max number of worker to be created in the pool (default 3)

FATUS_EQ_RETRY_TIME: time that a worker waits in order to be killed at empty queue events, in milliseconds (default 4000)

FATUS_WRK_STACK_TRSHLD: maximum number of iteration of single worker (default 10)

FATUS_MAX_FAIL: maximum number of fail for a job (default 10)

TODO

My ideas for future improvements are:

  • create a way to manage "blocked-blocking" jobs
  • a visual presentation of the queue(s) state
  • extensive testing with multiple instances
  • possibility to manage multiple queues

Contributions

If you find bugs or want to change functionality, feel free to fork and pull request.

Notes

The library use the es6 language, please make sure your node version supports it (we currently used 5.7). The library is still in early stage, please consider some testing.

Cheers from digitalx.