Uses old Rust 2015

0.1.1 Sep 13, 2018
0.1.0 May 30, 2018

#25 in #consul

MIT license

15KB
284 lines

diplomat_rust

Service discovery client for Rust based on consul

dependence

You need to set environment variable for test env SERVICE_DISCOVERY_URI

e.g.

export SERVICE_DISCOVERY_URI=consul://discovery.dev.xx.com:8500

Usage

extern crate discovery_rust;

use discovery_rust::Discovery;

fn main() {
    let mut discovery = Discovery::new_discovery("mysql".to_string(), None);
    let addr = discovery.get_address();
    println!("{}", addr);
}

Load balance strategy

Support random and roundrobin.

Tricks

Also you can cover discovery uri by setting environment variable for debug. e.g. SERVICE_NAME -> redis

export REDIS_SERVICE_ADDRESS = '127.0.0.1:8080'

Todo

  • service registry
  • cache
  • unit test

Dependencies

~12MB
~233K SLoC