pylon
v0.0.24
Published
service-registry
Downloads
137
Readme
pylon (experimental)
___________________________
/ _ \
| ___ _ _ | | ___ ___ |
| | . || | || || . || | |
| | _||_ ||_||___||_|_| |
| |_| |___| |
\_________________________ / ____ ___
\| / . \ .-´/ \`-.
\____ \/ \___/ \__
\_`---´___`---´-´
/../..\ /..\..\
- portmanager with dnode-interface
- inspired by [seaport] - maybe you should use seaport!
cli
TBA
api
var pylon = require('pylon')()
pylon.config()
pylon.listen()
pylon.connect()
pylon.set()
pylon.get()
pylon.del()
pylon.subscribe()
pylon.unsubscribe()
pylon.use()
plumbing
package.json
{ "name" : "my-balancer"
, "version" : "0.0.0"
, "dependencies" :
{ "pylon" : "*"
, "pylon-balancer" : "*"
, "pylon-web" : "*"
}
, "scripts" :
{ "start-balancer" : "node ./balancer.js &"
, "start-app" : "node ./app.js &"
, "test" : "curl http://localhost:9901/ -H 'Host:foo.bar.com'"
}
}
balancer.js
var balancer = require('pylon-balancer')
var web = require('pylon-web')
var pylon = require('pylon')
balancer().listen(1334).connect(1337)
web().listen(1335).connect(1337)
pylon().listen(1337)
// or:
// var dnode = require('dnode')
// var pylonServer = dnode(pylon).listen(1337)
// pylonServer.on('ready',function(){
// dnode().connect(1337,function(remote,conn){
// dnode(balancer(remote)).listen(1334)
// dnode(web(remote)).listen(1335)
// })
// })
app.js
var express = require('express')
, app = express.createServer()
, port = Math.floor(Math.random() * 40000 + 10000)
, pylon = require('pylon')
app.get('/',function(req,res){
res.end('hello! i am actually running on port: '+port)
})
app.listen(port,function(){
pylon.connect(1337,function(remote,conn){
remote.set
( { port: port, host: 'localhost' }
, { balancer :
{ route : 'foo.bar.com'
, weight : 10 }
, permanent : true
}
, function(err, data) {
if (err) return console.error(err)
console.log(data)
}
)
})
})