fn get_peer()

in src/plugin/plugin_memcached.rs [369:390]


fn get_peer(this: &mut ZObj, key: ZVal) -> String {
    let f = || {
        let info = this.call(&"getServerByKey".to_ascii_lowercase(), [key])?;
        let info = info.as_z_arr().context("Server isn't array")?;
        let host = info
            .get("host")
            .context("Server host not exists")?
            .as_z_str()
            .context("Server host isn't string")?
            .to_str()?;
        let port = info
            .get("port")
            .context("Server port not exists")?
            .as_long()
            .context("Server port isn't long")?;
        Ok::<_, crate::Error>(format!("{}:{}", host, port))
    };
    f().unwrap_or_else(|err| {
        warn!(?err, "Get peer failed");
        "".to_owned()
    })
}