A message based router for building distributed systems
Clone or download
Peter Elger Peter Elger
Peter Elger and Peter Elger Publish
 - mu@2.1.4
 - mu-dns@1.0.5
 - mu-http@1.0.5
 - mu-local@1.0.9
 - mu-redis@1.0.9
 - mu-tcp@1.0.9
 - mu-transport@1.0.9
Latest commit c084ec6 Mar 1, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example monorepo Nov 7, 2016
packages Publish Mar 1, 2017
test fixed object caching issue in dns tests (#77) Feb 22, 2017
.gitignore Modified define function to take pattern as first argument and added … ( Dec 14, 2016
.travis.yml monorepo Nov 7, 2016
LICENSE monorepo Nov 7, 2016
README.md dep badges for monorepo Nov 10, 2016
collaborators.md Dns adapter (#75) Feb 22, 2017
lerna.json monorepo Nov 7, 2016
package.json updated package deps Feb 22, 2017

README.md

mu

npm travis coveralls

  • Sponsor: nearForm
  • Status: Experimental

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

  • npm test - to run tests. Tests may be written at the top level, and in individual packages, this command will ensure all tests are run.
  • npm run lint - lint the code
  • npm run coverage - run and open a coverage report.
  • npm run check - test and lint (used as a precommit hook)

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.