clusterfuck
WIP cluster management.
Write your code once and use configuration to route your services together. You should be able to define whether cluster('foo')
requires a local module or returns a http request to http://foo/
without touching code.
Every service is a Stream
, so it works either required locally or over the network.
Example
var clusterfuck = ;var cluster = ; var header = ;// over http; var layout = ;// require()d locally;
You can for example use minimist to inject service location through stdarg:
var minimist = ;var clusterfuck = ;var cluster = ; var header = ;// over http; var layout = ;// require()d locally;
and launch via:
$ node server.js --@mic/site-header=http://localhost:8000
Adapters
If no mapping is provided for a service, it will simply be require()
d.
HTTP
var cluster = ;var header = ;
will result in this request to get a header stream:
GET http://header.mic.com/section?some=opts
Nested properties are supported via qs.
Caching
var cluster = ; var header = ; ; // fill the cache// ...; // use the cache// ...; // new args -> new cache
Installation
$ npm install clusterfuck
API
var cluster = clusterfuck(map)
Create a cluster with given map
from service names to remote locations.
cluster.events
EventEmitter, see Events.
var service = cluster(name)
Create a constructor for the service known as name
.
service([args, ][opts])
Create a readable stream from service
with optional string args
and an array of opts
.
Events
The following events will be emitted for every outgoing request (read: not a require()
), and will have the following properties:
request
id
transport
url
response
id
transport
url
status
There is a simple debug logger included, set the environment variable CLUSTERLOG=true
to enable it.
Example:
clusterevents;
License
MIT