npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grenache-grape

v0.9.12

Published

Granache Grape - DHT for micro-services

Downloads

291

Readme

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

// Install global (run binary)
npm install -g grenache-grape
// Install locally to project (programmatic approach)
npm install --save grenache-grape

Run in Binary Mode

grape --help

Usage: grape --dp <dht-port> --aph <http-api-port> --bn <nodes> [--b
bind-to-address]

Options:
  -b, --bind                 Listening host                             [string]
  --dp, --dht_port           DHT listening port              [number] [required]
  --dc, --dht_concurrency    DHT concurrency                            [number]
  --dht_maxTables            DHT max tables                             [number]
  --dht_maxValues            DHT max values                             [number]
  --bn, --bootstrap          Bootstrap nodes                 [string] [required]
  --aph, --api_port          HTTP api port                   [number] [required]
  --dht_peer_maxAge, --dpa   Max age for peers in DHT                   [number]
  --cache_maxAge             Maximum cache age                          [number]
  --dnl, --dht_nodeLiveness  Interval in ms to check for dead nodes     [number]
  --check_maxPayloadSize     Limit for max payload size                 [number]
  --help                     Show help                                 [boolean]
  --version                  Show version number                       [boolean]
// Run 3 Grapes
grape -b 127.0.0.1 --dp 20001 --dc 32 --aph 30001 --bn '127.0.0.1:20002,127.0.0.1:20003'
grape --dp 20002 --aph 40001 --dc 32 --bn '127.0.0.1:20001,127.0.0.1:20003'
grape --dp 20003 --aph 50001 --dc 32 --bn '127.0.0.1:20001,127.0.0.1:20002'

Integrate in your Code

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: 30001
})

g.start()

API

Class: Grape

new Grape(options)

  • options <Object> Options for the link
    • host <String> IP to bind to. If null, Grape binds to all interfaces
    • dht_maxTables <Number> Maximum number of DHT tables
    • dht_maxValues <Number> Maximum number of DHT values
    • dht_port <Number> Port for DHT
    • dht_concurrency <Number> Concurrency for DHT
    • dht_bootstrap: <Array> Bootstrap servers
    • dht_peer_maxAge <Number> maxAge for DHT peers
    • api_port <Number> Grenache API HTTP Port

Event: 'ready'

Emitted when the DHT is fully bootstrapped.

Event: 'listening'

Emitted when the DHT is listening.

Event: 'peer'

Emitted when a potential peer is found.

Event: 'node'

Emitted when the DHT finds a new node.

Event: 'warning'

Emitted when a peer announces itself in order to be stored in the DHT.

Event: 'announce'

Emitted when a peer announces itself in order to be stored in the DHT.

Implementations

Node.JS Clients

  • 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

Ruby Clients

  • https://github.com/bitfinexcom/grenache-ruby-ws: WebSocket based Grape microservices
  • https://github.com/bitfinexcom/grenache-ruby-http: HTTP based Grape microservices

CLI Clients

  • https://github.com/bitfinexcom/grenache-cli: Command Line Interface for Grape microservices