Skip to content

Rust client libray for Consul HTTP API

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

armersong/consul-rust

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

consul-rust

Build Status

Documentation here.

Rust client libray for Consul HTTP API

Usage

#![allow(unused_must_use)]

use consul::Client;
use consul::Config;
use consul::catalog::Catalog;

fn main(){
    let mut config = Config::new().unwrap();
    config.address = String::from("http://localhost:8500");
    let client = Client::new(config);
    let nodes = client.nodes(None);
    nodes.map(|(nodes, _)|{
        println!("nodes: {:?}", nodes);
       for node in nodes.iter() {
           println!("node {}: {:?}", node.ID, client.node(node.ID.as_str(), None));
       }
    });

    let res = client.services(None);
    res.map(|(m, _)|{
        println!("services: {:?}", m);
        for key in m.keys() {
            let service = client.service(key.as_str(), None);
            println!("service {}: {:?}", key, service);
        }
    });
}

For more example, see the tests .

Installation

Simply include the consul-rust in your Cargo dependencies.

[dependencies]
consul = "0.4"

About

Rust client libray for Consul HTTP API

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 99.3%
  • Shell 0.7%