0.2.2 • Published 10 years ago

causeway v0.2.2

Weekly downloads
33
License
-
Repository
-
Last release
10 years ago

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

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago