causeway

0.2.2 • Public • Published

causeway

wercker status

Link individual or groups applications together via Redis to create modular full stack node systems.

API

    var causeway = require('../../index')()
    // register redis profiles
    .register({
        'default': {
            port: 6379,
            host: '0.0.0.0'
        },
        'special': {
            port: 5678,
            host:'0.0.0.0'
        }
    });
 
    /**
     * Host
     */
 
    // listen on a redis connection
    causeway.listen('default')
 
    // switch on job events
    .when('load_user', function (job, args, done) {
        console.log('Process job: ' + job + ', with args: ' + JSON.stringify(args, null, 4));
 
        // call callback on completion with response
        done({ status: 'success' });
 
        // if you have an error, pass it in `.err`
        // so the client can have their promises rejected
        done({ err: 'You did something totally wrong' });
    });
 
    /**
     * Client
     */
 
    // Connect to host via redis profile
    var client = causeway.using('default');
 
    // On handshake completion
    client.on('handshake', function (key) {
        console.log('Handshake with client with key: ' + key);
 
        // request job from host
        client.request('load_user', 'iyad').then(function (response) {
 
            // callback on job completion
            console.log('Response for load_user job: '+ JSON.stringify(response));
        }, function (response) {
            console.log('We had an error: ' + response.err);
        });
    });
 

Tests

npm install && npm test

Benchmarks

npm run bench

/causeway/

    Package Sidebar

    Install

    npm i causeway

    Weekly Downloads

    1

    Version

    0.2.2

    License

    none

    Last publish

    Collaborators

    • iyadassaf