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
Add grenache-rust to your cargo.toml
file:
grenache-rust = { git = "https://github.com/bitfinexcom/grenache-rust.git" }
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'
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();
}
Licensed under Apache License, Version 2.0
- Rust - Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.
- serde_json - Apache License, Version 2.0 or MIT
- uuid - Apache License, Version 2.0 or MIT
- log - Apache License, Version 2.0 or MIT
- hyper - MIT license
- tokio - MIT license