Closed Jzow closed 3 years ago
Hello @Jzow ,
Yes, this bug has been fixed a while ago and even contains a test-case: https://github.com/pierresouchay/consul-rust/blob/master/tests/catalog.rs#L14
Try using version 0.4.1 (available as crate, it should now work well).
Can you please close the issue if it fixes the issue for you?
Regards
@pierresouchay Thank you very much for your prompt reply,I will try to write a test case,:)
Hello @pierresouchay
I'm trying to register the service to the consumer through an Rust API, which is a bit similar to Java annotation registration of the consumer service, Do you have a demo or any good suggestions,I think the bug has been solved. You can add a question label. Thank you very much
extern crate consul;
use consul::{Client, Config};
#[test]
fn ds_test() {
use consul::catalog::Catalog;
let mut config = Config::new_from_env().unwrap();
config.address = String::from("http://192.168.20.23:8500/");
let client = Client::new(config);
let r = client.datacenters().unwrap();
assert_eq!(r.0, ["dc1"]);
}
#[test]
fn ds_services_test() {
use consul::catalog::Catalog;
let mut config = Config::new().unwrap();
config.address = String::from("http://192.168.20.23:8500/");
let client = Client::new(config);
let r = client.services(Option::None).unwrap();
assert_ne!(r.0.len(), 0);
match r.0.get("consul") {
None => panic!("Should have a Consul service"),
Some(val) => assert_eq!(val.len(), 0), // consul has no tags
}
}