fn new()

in src/samplers/memcache/mod.rs [30:57]


    fn new(common: Common) -> Result<Self, anyhow::Error> {
        if !common.config.samplers().memcache().enabled() {
            return Ok(Self {
                address: "localhost:11211".to_socket_addrs().unwrap().next().unwrap(),
                common,
                stream: None,
            });
        }
        if common.config.samplers().memcache().endpoint().is_none() {
            return Err(format_err!("no memcache endpoint configured"));
        }
        let endpoint = common.config.samplers().memcache().endpoint().unwrap();
        let mut addrs = endpoint.to_socket_addrs().unwrap_or_else(|_| {
            fatal!("ERROR: endpoint address is malformed: {}", endpoint);
        });
        let address = addrs.next().unwrap_or_else(|| {
            fatal!("ERROR: failed to resolve address: {}", endpoint);
        });
        let sampler = Self {
            address,
            common,
            stream: None,
        };
        if sampler.sampler_config().enabled() {
            sampler.register();
        }
        Ok(sampler)
    }