Skip to content
/ mu Public

A message based router for building distributed systems

License

Notifications You must be signed in to change notification settings

apparatus/mu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A message based router for building distributed systems

Resources

License

Stars

Watchers

Forks

Packages