pub fn configure(settings: &Settings, _components: &[ComponentInfo]) -> Result<Option<ComponentSender>, ComponentError> {
    // ensure our service is configure in services
    if !settings.services.contains("AliceService") {
        log::debug!("alice service is not configured");
        return Ok(None);
    }
    // find ourself in the list
    for c in &settings.coordinator {
        if let Some(value) = c.get("AliceCoordinator") {
            let maybe_coordinator = match value {
                CoordinatorVariant::SimpleTcpConfig { tcp_address, .. } => Some(AliceCoordinator {
                    net_sender: get_network_sender(),
                    bind_addr: tcp_address.to_string(),
                }),
                #[allow(unreachable_patterns)] // in case it becomes reachable, we want to know
                _ => None,
            };

            if let Some(coordinator) = maybe_coordinator {
                if coordinator.bind_addr.parse::<SocketAddr>().is_err() {
                    log::error!("Unable to parse {} into a SocketAddr", &coordinator.bind_addr);
                    continue;
                }
                log::debug!("alice service selected configuration: {:#?}", value);
                // create the AliceCoordinator machine with a NetCmd communication channel
                let (m, sender) = executor::connect::<_, NetCmd>(coordinator);
                // bind the server address to the coordinator
                get_network_sender()
                    .send(NetCmd::BindListener(m.bind_addr.clone(), sender))
                    .expect("BindListener failed");
                // add a ComponentCmd communication channel to the coordinator
                let sender = executor::and_connect::<_, ComponentCmd>(&m);
                return Ok(Some(sender));
            }
        }
    }
    log::warn!("The configuration for the alice service coordinator was not found.");
    Err(ComponentError::BadConfig(
        "The configuration for the alice service coordinator was not found.".to_string(),
    ))
}
// The ugliest part of a coordinator is the configuration parsing.
The ugliest part of a coordinator is the configuration parsing.
The ugliest part of a coordinator is the configuration parsing .
pub fn configure(settings: &Settings, _components: &[ComponentInfo]) -> Result<Option<ComponentSender>, ComponentError> {
    // ensure our service is configure in services
    if !settings.services.contains("AliceService") {
        log::debug!("alice service is not configured");
        return Ok(None);
    }
    // find ourself in the list
    for c in &settings.coordinator {
        if let Some(value) = c.get("AliceCoordinator") {
            let maybe_coordinator = match value {
                CoordinatorVariant::SimpleTcpConfig { tcp_address, .. } => Some(AliceCoordinator {
                    net_sender: get_network_sender(),
                    bind_addr: tcp_address.to_string(),
                }),
                #[allow(unreachable_patterns)] // in case it becomes reachable, we want to know
                _ => None,
            };
            if let Some(coordinator) = maybe_coordinator {
                if coordinator.bind_addr.parse::<SocketAddr>().is_err() {
                    log::error!("Unable to parse {} into a SocketAddr", &coordinator.bind_addr);
                    continue;
                }
                log::debug!("alice service selected configuration: {:#?}", value);
                // create the AliceCoordinator machine with a NetCmd communication channel
                let (m, sender) = executor::connect::<_, NetCmd>(coordinator);
                // bind the server address to the coordinator
                get_network_sender()
                    .send(NetCmd::BindListener(m.bind_addr.clone(), sender))
                    .expect("BindListener failed");
                // add a ComponentCmd communication channel to the coordinator
                let sender = executor::and_connect::<_, ComponentCmd>(&m);
                return Ok(Some(sender));
            }
        }
    }
    log::warn!("The configuration for the alice service coordinator was not found.");
    Err(ComponentError::BadConfig(
        "The configuration for the alice service coordinator was not found.".to_string(),
    ))
}
pub fn configure ( settings : & Settings , _components : & [ ComponentInfo ] ) -> Result < Option < ComponentSender > , ComponentError > { // ensure our service is configure in services if ! settings . services . contains ( " " ) { log :: debug ! ( " " ) ; return Ok ( None ) ; } // find ourself in the list for c in & settings . coordinator { if let Some ( value ) = c . get ( " " ) { let maybe_coordinator = match value { CoordinatorVariant :: SimpleTcpConfig { tcp_address , .. } => Some ( AliceCoordinator { net_sender : get_network_sender ( ) , bind_addr : tcp_address . to_string ( ) , } ) , # [ allow ( unreachable_patterns ) ] // in case it becomes reachable, we want to know _ => None , } ; if let Some ( coordinator ) = maybe_coordinator { if coordinator . bind_addr . parse :: < SocketAddr > ( ) . is_err ( ) { log :: error ! ( " " coordinator bind_addr ) ; continue ; } log :: debug ! ( " " value ) ; // create the AliceCoordinator machine with a NetCmd communication channel let ( m , sender ) = executor :: connect :: < _ , NetCmd > ( coordinator ) ; // bind the server address to the coordinator get_network_sender ( ) . send ( NetCmd :: BindListener ( m . bind_addr . clone ( ) , sender ) ) . expect ( " " ) ; // add a ComponentCmd communication channel to the coordinator let sender = executor :: and_connect :: < _ , ComponentCmd > ( & m ) ; return Ok ( Some ( sender ) ) ; } } } log :: warn ! ( " " ) ; Err ( ComponentError :: BadConfig ( " " . to_string ( ) , ) ) }
The ugliest part of a coordinator is the configuration parsing.
The ugliest part of a coordinator is the configuration parsing .
settings
&Settings
_components
&[ComponentInfo]