apparatus / mu

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

support func/local transport on same instance #50

Open davidmarkclements opened 8 years ago

davidmarkclements commented 8 years ago

currently for in-process we have to do

var func = require('mu/drivers/func')
var createMu = require('mu')
var mu1 = createMu()
var mu2 = createMu()
mu1.inbound('*', func())
mu2.outbound('*', func({target: mu1})

I think this should be simpler, particularly for the browser case

var func = require('mu/drivers/func')
var mu = require('mu')()
mu.inbound('*', func())
mu.outbound('*', func({target: mu})) // currently causes max stack error on dispatch

or preferably, no need to specify target:

var func = require('mu/drivers/func')
var mu = require('mu')()
mu.inbound('*', func())
mu.outbound('*', func())

This allows for something like

var func = require('mu/drivers/func')
var http = require('mu/drivers/http')
var mu = require('mu')()
mu.inbound('*', http(opts))
mu.inbound({role: 'local-state'}, func())
mu.outbound({role: 'local-state'}, func())
davidmarkclements commented 8 years ago

cc @mcollina @pelger

mcollina commented 8 years ago

Can you please update the latest two examples to two mu instances?

BTW, I think this should be: mu1.outboud('*', mu2)