Skip to content

Commit

Permalink
refactor(service/etcd): use EtcdConfig in from_map (#3703)
Browse files Browse the repository at this point in the history
  • Loading branch information
G-XD authored Dec 1, 2023
1 parent 3890e9d commit ca433b1
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions core/src/services/etcd/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,10 @@ impl Builder for EtcdBuilder {
type Accessor = EtcdBackend;

fn from_map(map: HashMap<String, String>) -> Self {
let mut builder = EtcdBuilder::default();

map.get("root").map(|v| builder.root(v));
map.get("endpoints").map(|v| builder.endpoints(v));
map.get("username").map(|v| builder.username(v));
map.get("password").map(|v| builder.password(v));
map.get("ca_path").map(|v| builder.ca_path(v));
map.get("cert_path").map(|v| builder.cert_path(v));
map.get("key_path").map(|v| builder.key_path(v));

builder
EtcdBuilder {
config: EtcdConfig::deserialize(ConfigDeserializer::new(map))
.expect("config deserialize must succeed"),
}
}

fn build(&mut self) -> Result<Self::Accessor> {
Expand Down

0 comments on commit ca433b1

Please sign in to comment.