Grenache Grape implementation
Grenache is a micro-framework for connecting microservices. Its simple and optimized for performance.
Internally, Grenache uses Distributed Hash Tables (DHT, known from Bittorrent) for Peer to Peer connections. You can find more details how Grenche internally works at the Main Project Homepage.
Grapes are the backbone of Grenache. They manage the DHT, the base of our virtual network.
// Install global (run binary)
npm install -g grenache-grape
// Install locally to project (programmatic approach)
npm install --save grenache-grape
grape --help
Usage: grape --dp <val> --awp <val> --aph <val> --bn <val>
Options:
-b, --bind Listening host [string]
--dp, --dht_port DHT listening port [number] [required]
--aph, --api_port_http HTTP api port [number] [required]
--bn, --bootstrap Bootstrap nodes [string] [required]
--help Show help [boolean]
--version Show version number [boolean]
// Run 3 Grapes
grape -b 127.0.0.1 --dp 20001 --aph 30001 --bn '127.0.0.1:20002,127.0.0.1:20003'
grape --dp 20002 --aph 40001 --bn '127.0.0.1:20001,127.0.0.1:20003'
grape --dp 20003 --aph 50001 --bn '127.0.0.1:20001,127.0.0.1:20002'
const Grape = require('grenache-grape').Grape
const g = new Grape({
// host: '127.0.0.1', // if undefined the Grape binds all interfaces
dht_port: 20001,
dht_bootstrap: [
'127.0.0.1:20002'
],
api_port_http: 30001
})
g.start()
options
<Object> Options for the linkhost
<String> IP to bind to. If null, Grape binds to all interfacesdht_maxTables
<Number> Maximum number of DH tables- `dht_port <Number> Port for DHT
dht_bootstrap
: <Array> Bootstrap serversapi_port_http
<Number> Grenache API HTTP Porttimeslot
<Number> Timeslot used for lookup
Emitted when the DHT is fully bootstrapped.
Emitted when the DHT is listening.
Emitted when a potential peer is found.
Emitted when the DHT finds a new node.
Emitted when a peer announces itself in order to be stored in the DHT.
Emitted when a peer announces itself in order to be stored in the DHT.
- https://github.com/bitfinexcom/grenache-nodejs-ws: WebSocket based Grape microservices
- https://github.com/bitfinexcom/grenache-nodejs-http: HTTP based Grape microservices
- https://github.com/bitfinexcom/grenache-nodejs-zmq: ZeroMQ based Grape microservices
- https://github.com/bitfinexcom/grenache-nodejs-ws-tls: WebSocket based Grape microservices with TLS support
- https://github.com/bitfinexcom/grenache-ruby-ws: WebSocket based Grape microservices
- https://github.com/bitfinexcom/grenache-ruby-http: HTTP based Grape microservices