apparatus / mu

A message based router for building distributed systems
MIT License
26 stars 1 forks source link

mu

npm travis coveralls

Mu is a message based router for building distributed systems. It allows messages to be routed and handled across various transports. Mu is aggressively light weight to ensure ease of use and speed of execution.

Install

To install mu, simply use npm,

$ npm install mu

Example

service-a.js:

const mu = require('mu')({dev: process.NODE_ENV !== 'production'})
const tcp = require('mu-tcp')

// define routing:

mu.inbound({role: 'some'}, tcp.server({port: 3000, host: '127.0.0.1'}))

// define patterns:

mu.define({role: 'some', cmd: 'thing'}, function (args, cb) {
  if (!args.pattern.user) {
    return cb(mu.error('no user found!'))
  }
  cb(null, {some: 'data'})
})

service-b.js:

const mu = require('mu')({dev: process.NODE_ENV !== 'production'})
const tcp = require('mu-tcp')

// define routing:

mu.outbound({role: 'some'}, tcp.client({port: 3000, host: '127.0.0.1'}))

// define patterns:

mu.dispatch({role: 'some', cmd: 'thing', user: 'me :)'}, function (err, result) {
  if (err) {
    return console.error(err)
  }
  console.log(result)
})

API

Packages

The mu repo is managed as a monorepo, composed of multiple npm packages.

Package Version Dependencies
mu npm Dependency Status
mu-error npm Dependency Status
mu-local npm Dependency Status
mu-tcp npm Dependency Status
mu-http N/A Dependency Status
mu-redis npm Dependency Status
mu-balance npm Dependency Status
mu-tee npm Dependency Status
mu-router npm Dependency Status
mu-transport npm Dependency Status

Development

The mu repository is Monorepo, managed with lerna

Each folder in packages is a distinct module, separately published to npm.

But general admin such as tests, linting, coverage, and build pipeline is managed at this repositories top level.

Getting Started

Clone:

$ git clone https://github.com/apparatus/mu

Setup:

$ npm run setup 

This runs the lerna bootstrap command, which installs all sub-deps and links common packages together.

Our dev environment is now set up.

QA

Releasing

npm run release

This runs the lerna publish command, which discovers packages that have changes, prompts for a version, then publishes each to npm, and creates a git release for the Github repository.

Contributors

Peter Elger

https://github.com/pelger

https://twitter.com/pelger

David Mark Clements

https://github.com/davidmarkclements

https://twitter.com/davidmarkclem

Dean McDonnell

https://github.com/mcdonnelldean

https://twitter.com/mcdonnelldean

Matteo Collina

https://github.com/mcollina

https://twitter.com/matteocollina

License

Copyright Peter Elger 2016 & Contributors, Licensed under MIT.