Comments (2)
@jimmycuadra Or just add members::leader(&client)
for getting leader, url is /v2/members/leader
from rust-etcd.
I solved it by adding this function into member.rs :)
/// Leader of members
///
/// # Parameters
///
/// * client: A `Client` to use to make the API call.
pub fn leader<C>(
client: &Client<C>,
) -> impl Future<Item = Response<Member>, Error = Vec<Error>> + Send
where
C: Clone + Connect,
{
let http_client = client.http_client().clone();
first_ok(client.endpoints().to_vec(), move |member| {
let url = build_url(member, "/leader");
let uri = Uri::from_str(url.as_str())
.map_err(Error::from)
.into_future();
println!("uri: {:?}", uri);
let http_client = http_client.clone();
let response = uri.and_then(move |uri| http_client.get(uri).map_err(Error::from));
response.and_then(|response| {
let status = response.status();
let cluster_info = ClusterInfo::from(response.headers());
let body = response.into_body().concat2().map_err(Error::from);
body.and_then(move |ref body| {
if status == StatusCode::OK {
match serde_json::from_slice::<Member>(body) {
Ok(data) => {
/*
for member in data.members {
println!("");
}
*/
println!("data: {:?}", data);
Ok(Response {
data: data,
cluster_info,
})
},
Err(error) => Err(Error::Serialization(error)),
}
} else {
match serde_json::from_slice::<ApiError>(body) {
Ok(error) => Err(Error::Api(error)),
Err(error) => Err(Error::Serialization(error)),
}
}
})
})
})
}
from rust-etcd.
Related Issues (14)
- Mimic --forever option of etcdctl watch HOT 2
- Build failure under Rust 0.11.0 HOT 3
- Support for etcd3 HOT 16
- Multithread support HOT 2
- Support for managing users, roles HOT 6
- Connection leak from watch timeout. HOT 5
- watch_recursive test is not deterministic HOT 1
- 0.9.0 does not with tokio 1.x
- Allow using certificates to connect to the cluster.
- Relicense under dual MIT/Apache-2.0
- etcd 2.2 HOT 3
- build fails to resolve syntex::Registry HOT 1
- Any way to cancel watch? HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-etcd.