@keegpt/radonjs
An event backbone for microservices architectures using express
Last updated 12 days ago by josepgomes .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @keegpt/radonjs 
SYNC missed versions from official npm registry.

RadonJS

An event backbone for microservices architectures using express

Version: Alpha.2

Installation

Use the package manager npm to install radonjs.

npm install @keegpt/radonjs

Server

const radon = require('../lib').default;

(() => {
    const server = new radon.Server();
})();

Clients

const radon = require('../lib').default;

(() => {
    const client = new radon.Client({
        port: 3011,
        onReady: async () => {
            await client.register();

            client.subscribe('test', async (data) => {
                console.log('3011 received:', data);
                return { success: true };
            });

            client.subscribe('another/test', async (data) => {
                console.log('3011 received:', data);
            });
        }
    });
})();
const radon = require('../lib').default;

(() => {
    const client = new radon.Client({
        port: 3012,
        onReady: async () => {
            await client.register();

            setTimeout(async () => {
                try {
                    const result = await client.get('test', { some: 'data' });
                    console.log('3012 received', result);

                    client.send('another/test', { more: 'data' });
                } catch (error) {
                    console.error(error)
                }
            }, 1000);
        }
    });
})();

Todo

Some of this are simple to do, i'm just trying to find time :(

  • Remove request-promise dependency (use native http/https)
  • Allow to customize event timeout and concurrency values
  • Create a system to get all updated stats from each event
  • A error handling system
  • A debug system
  • A microservice recovery system
  • Implement redis as core

Docs

Server options

Property Description
app An express application
path Internal radon router path

Client options

Property Description
app An express application
host Client host
port Client port
path Internal radon router path
serverHost Server host
serverPort Server port
serverPath Server internal radon router path
onReady Ready to work callback

Client methods

subscribe(eventName, callback)

(() => {
    client.subscribe('EVENT_NAME', async (data: any) => {
        // logic
        // we can return data to the publisher, just returning something in this function
    });
})()

send(eventName, data)

(() => {
    client.send('EVENT_NAME', { some: 'data' });
})()

get(eventName, data)

(async () => {
    const result = await client.get('EVENT_NAME', { some: 'data' });
    console.log(result);
})()

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Current Tags

  • 0.1.0                                ...           latest (12 days ago)

4 Versions

  • 0.1.0                                ...           12 days ago
  • 0.0.1-beta.2                                ...           15 days ago
  • 0.0.1-beta.1                                ...           16 days ago
  • 0.0.1-beta.0                                ...           16 days ago
Maintainers (1)
Downloads
Today 0
This Week 4
This Month 42
Last Day 4
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |