(this: &mut ZObj, key: ZVal)
| 367 | } |
| 368 | |
| 369 | fn get_peer(this: &mut ZObj, key: ZVal) -> String { |
| 370 | let f = || { |
| 371 | let info = this.call(&"getServerByKey".to_ascii_lowercase(), [key])?; |
| 372 | let info = info.as_z_arr().context("Server isn't array")?; |
| 373 | let host = info |
| 374 | .get("host") |
| 375 | .context("Server host not exists")? |
| 376 | .as_z_str() |
| 377 | .context("Server host isn't string")? |
| 378 | .to_str()?; |
| 379 | let port = info |
| 380 | .get("port") |
| 381 | .context("Server port not exists")? |
| 382 | .as_long() |
| 383 | .context("Server port isn't long")?; |
| 384 | Ok::<_, crate::Error>(format!("{}:{}", host, port)) |
| 385 | }; |
| 386 | f().unwrap_or_else(|err| { |
| 387 | warn!(?err, "Get peer failed"); |
| 388 | "".to_owned() |
| 389 | }) |
| 390 | } |
no outgoing calls
no test coverage detected