1.0.8 • Published 8 years ago

ajwain v1.0.8

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

Ajwain

SDK to add scheduling mechanisms backed by Hot Sauce API

Build Status Coverage Status npm

Installation

npm install ajwain

Testing

npm run test

Code Coverage

Code Coverage provided by Istanbul with hooks for coveralls. To see coverage report run

npm run cover

Usage

var Ajwain = require('ajwain');
var Logger = require('salt-pepper').Logger;
var os = require('os');

var config = {
    pollInterval: 1000, //time to poll in ms
    couchbase: {
        cluster: ['http://couchbase.host:8091'],
        bucket: {
            name: 'bucket_name',
            password: 'p@$$w0rd'
        }
    },
    logger: {
        console: {enabled: true, options: {level: 'debug'}},
        file: {enabled: false, options: {level: 'debug', filename: "ajwain.log"}}
    }
    
}

var ajwain = new Ajwain(config);

//capabilities that this worker understands
var codes = ['code1', 'code2'];

var options = {
    jobCodes: codes,
    caller: os.hostname()
};

var logger = new Logger(config.logger);

ajwain.registerErrorHandler(function(err){
    logger.error('i met an error', err);
    }
);

ajwain.registerJobHandler(options, function(job){
    logger.debug('found a job ' + JSON.stringify(job));

    var sleepTime = Math.random() * (1000) + 15000;
    logger.debug('sleeping for a ' + sleepTime +'seconds');

    setTimeout(function(){
        logger.debug('completing job');
        ajwain.completeJob(job, options);
    }, sleepTime);

});
1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago