/grenache-rust

Primary LanguageRustApache License 2.0Apache-2.0

Grenache Rust HTTP 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

Setup

Install

Add grenache-rust to your cargo.toml file:

grenache-rust = { git = "https://github.com/bitfinexcom/grenache-rust.git" }

Other Requirements

Install Grenache Grape: https://github.com/bitfinexcom/grenache-grape:

npm i -g grenache-grape
// Start 2 Grapes
grape --dp 20001 --aph 30001 --bn '127.0.0.1:20002'
grape --dp 20002 --aph 40001 --bn '127.0.0.1:20001'

Examples

The following will annonce the rest:net:util service on port 31337 and then confirm that the service can be looked up using the GrenacheClient object.

extern crate grenache_rust;

use grenache_rust::GrenacheClient;
use grenache_rust::Grenache;
use std::{thread, time};

fn main(){
    let service = "rest:net:util";
    let service_port = 31_337u16;
    let api_url = "http://127.0.0.1:30001";
    let mut client = GrenacheClient::new(api_url);
    client.start_announcing(service, service_port ).unwrap();
    thread::sleep(time::Duration::from_secs(1));
    println!("Service at: {}",client.lookup(service).unwrap());
    client.stop_announcing(service).unwrap();
}

Licensing

Licensed under Apache License, Version 2.0

Licenses for dependencies