pub fn factory(console: &bool,
               flush_interval_seconds: i32,
               graphite: &bool,
               graphite_global_prefix: &str,
               graphite_counter_prefix: &str,
               graphite_gauge_prefix: &str,
               graphite_timer_prefix: &str,
               graphite_host: &str,
               graphite_port: &u16,
               statsd: &bool,
               statsd_host: &str,
               statsd_port: &u16,
               statsd_hosts: &str,
               statsd_packet_limit: &usize,
               zeromq_backend: &bool,
               zeromq_hosts: &str)
               -> Box<[Box<dyn Backend>]> {
    let mut backends: Vec<Box<dyn Backend>> = Vec::with_capacity(2);
    if *console {
        backends.push(Box::new(console::Console::new()));
    }
    if *graphite {
        backends.push(Box::new(graphite::Graphite::new(
            graphite_host, *graphite_port,
            graphite_global_prefix, graphite_counter_prefix,
            graphite_gauge_prefix, graphite_timer_prefix,
            flush_interval_seconds
        )));
    }
    if *statsd {
        let mut hosts = "".to_string();
        let stats_deprecated_host = format!("{}:{},", statsd_host, statsd_port);
        if stats_deprecated_host != "127.0.0.1:0," {
            eprintln!("--statsd-host and --statsd-port flags are deprecated, please use --statsd-hosts instead.");
            hosts += &stats_deprecated_host;
        }
        hosts += &*statsd_hosts;
        let mut hosts_vec: Vec<String> =
            hosts
            .split(",").map(|host| host.trim().to_string())
            .filter(|host| !host.is_empty())
            .collect();
        hosts_vec.sort();
        hosts_vec.dedup();
        backends.push(Box::new(statsd::Statsd::new(
            hosts_vec, *statsd_packet_limit
        )))
    }
    if *zeromq_backend {
        let hosts = zeromq_hosts;
        let mut hosts_vec: Vec<String> = hosts
            .split(",")
            .map(|host| host.trim().to_string())
            .filter(|host| !host.is_empty())
            .collect();
        hosts_vec.sort();
        hosts_vec.dedup();
        if hosts_vec.len() > 0 {
            backends.push(Box::new(statsd_zmq::StatsdZmq::new(hosts_vec)))
        }
    }
    backends.into_boxed_slice()
}
/// Creates the collection of backends based on the paraemeters
///
Creates the collection of backends based on the paraemeters
Creates the collection of backends based on the paraemeters
pub fn factory(console: &bool,
               flush_interval_seconds: i32,
               graphite: &bool,
               graphite_global_prefix: &str,
               graphite_counter_prefix: &str,
               graphite_gauge_prefix: &str,
               graphite_timer_prefix: &str,
               graphite_host: &str,
               graphite_port: &u16,
               statsd: &bool,
               statsd_host: &str,
               statsd_port: &u16,
               statsd_hosts: &str,
               statsd_packet_limit: &usize,
               zeromq_backend: &bool,
               zeromq_hosts: &str)
               -> Box<[Box<dyn Backend>]> {
    let mut backends: Vec<Box<dyn Backend>> = Vec::with_capacity(2);
    if *console {
        backends.push(Box::new(console::Console::new()));
    }
    if *graphite {
        backends.push(Box::new(graphite::Graphite::new(
            graphite_host, *graphite_port,
            graphite_global_prefix, graphite_counter_prefix,
            graphite_gauge_prefix, graphite_timer_prefix,
            flush_interval_seconds
        )));
    }
    if *statsd {
        let mut hosts = "".to_string();
        let stats_deprecated_host = format!("{}:{},", statsd_host, statsd_port);
        if stats_deprecated_host != "127.0.0.1:0," {
            eprintln!("--statsd-host and --statsd-port flags are deprecated, please use --statsd-hosts instead.");
            hosts += &stats_deprecated_host;
        }
        hosts += &*statsd_hosts;
        let mut hosts_vec: Vec<String> =
            hosts
            .split(",").map(|host| host.trim().to_string())
            .filter(|host| !host.is_empty())
            .collect();
        hosts_vec.sort();
        hosts_vec.dedup();
        backends.push(Box::new(statsd::Statsd::new(
            hosts_vec, *statsd_packet_limit
        )))
    }
    if *zeromq_backend {
        let hosts = zeromq_hosts;
        let mut hosts_vec: Vec<String> = hosts
            .split(",")
            .map(|host| host.trim().to_string())
            .filter(|host| !host.is_empty())
            .collect();
        hosts_vec.sort();
        hosts_vec.dedup();
        if hosts_vec.len() > 0 {
            backends.push(Box::new(statsd_zmq::StatsdZmq::new(hosts_vec)))
        }
    }
    backends.into_boxed_slice()
}
pub fn factory ( console : & bool , flush_interval_seconds : i32 , graphite : & bool , graphite_global_prefix : & str , graphite_counter_prefix : & str , graphite_gauge_prefix : & str , graphite_timer_prefix : & str , graphite_host : & str , graphite_port : & u16 , statsd : & bool , statsd_host : & str , statsd_port : & u16 , statsd_hosts : & str , statsd_packet_limit : & usize , zeromq_backend : & bool , zeromq_hosts : & str ) -> Box < [ Box < dyn Backend > ] > { let mut backends : Vec < Box < dyn Backend > > = Vec :: with_capacity ( 2 ) ; if * console { backends . push ( Box :: new ( console :: Console :: new ( ) ) ) ; } if * graphite { backends . push ( Box :: new ( graphite :: Graphite :: new ( graphite_host , * graphite_port , graphite_global_prefix , graphite_counter_prefix , graphite_gauge_prefix , graphite_timer_prefix , flush_interval_seconds ) ) ) ; } if * statsd { let mut hosts = " " . to_string ( ) ; let stats_deprecated_host = format ! ( " " statsd_host statsd_port ) ; if stats_deprecated_host != " " { eprintln ! ( " " ) ; hosts += & stats_deprecated_host ; } hosts += & * statsd_hosts ; let mut hosts_vec : Vec < String > = hosts . split ( " " ) . map ( | host | host . trim ( ) . to_string ( ) ) . filter ( | host | ! host . is_empty ( ) ) . collect ( ) ; hosts_vec . sort ( ) ; hosts_vec . dedup ( ) ; backends . push ( Box :: new ( statsd :: Statsd :: new ( hosts_vec , * statsd_packet_limit ) ) ) } if * zeromq_backend { let hosts = zeromq_hosts ; let mut hosts_vec : Vec < String > = hosts . split ( " " ) . map ( | host | host . trim ( ) . to_string ( ) ) . filter ( | host | ! host . is_empty ( ) ) . collect ( ) ; hosts_vec . sort ( ) ; hosts_vec . dedup ( ) ; if hosts_vec . len ( ) > 0 { backends . push ( Box :: new ( statsd_zmq :: StatsdZmq :: new ( hosts_vec ) ) ) } } backends . into_boxed_slice ( ) }
Creates the collection of backends based on the paraemeters
Creates the collection of backends based on the paraemeters
console
&bool
flush_interval_seconds
i32
graphite
&bool
graphite_global_prefix
&str
graphite_counter_prefix
&str
graphite_gauge_prefix
&str
graphite_timer_prefix
&str
graphite_host
&str
graphite_port
&u16
statsd
&bool
statsd_host
&str
statsd_port
&u16
statsd_hosts
&str
statsd_packet_limit
&usize
zeromq_backend
&bool
zeromq_hosts
&str