async fn build_dag(&mut self) -> Result<()> {
        let mut done: usize = 0;

        while let Some(r) = self.rx.recv().await {
            match r {
                Event::Resource(resource) => {
                    self.dag.add_node_to_dag(resource.clone());

                    if resource.enforcement_state == EnforcementState::Delete
                        || resource.enforcement_state == EnforcementState::DeleteDependent
                    {
                        // FIXME: This is redundant
                        if let Some(deps) = resource.dependencies {
                            for mut dep in deps {
                                if !self.clients.contains_key(&dep.type_) {
                                    dep.dependencies = self
                                        .clients
                                        .entry(dep.type_)
                                        // For handling clients required for dependent resources
                                        .or_insert(create_client(
                                            &resource.type_,
                                            &self.client_details,
                                            &self.config,
                                            self.dry_run,
                                        ))
                                        .dependencies(&dep)
                                        .await;

                                    done = done + 1; // newly created client does not send Shutdown event
                                } else {
                                    dep.dependencies = self
                                        .clients
                                        .get(&dep.type_)
                                        .unwrap()
                                        .dependencies(&dep)
                                        .await;
                                }

                                self.dag.add_node_to_dag(dep);
                            }
                        }
                    }
                }
                Event::Shutdown(_et) => {
                    done = done + 1;

                    if done == self.clients.keys().len() {
                        break;
                    }
                }
            }
        }

        if !is_dag(&self.dag.graph) {
            return Err(Error::Dag(
                "Failed constructing dependency graph of the resources".to_string(),
            ));
        }

        if let Some(dot) = self.dag.get_dot() {
            trace!("{}", dot);
        }

        Ok(())
    }
/// Builds a dependency graph of resources
Builds a dependency graph of resources
Builds a dependency graph of resources
async fn build_dag(&mut self) -> Result<()> {
        let mut done: usize = 0;
        while let Some(r) = self.rx.recv().await {
            match r {
                Event::Resource(resource) => {
                    self.dag.add_node_to_dag(resource.clone());
                    if resource.enforcement_state == EnforcementState::Delete
                        || resource.enforcement_state == EnforcementState::DeleteDependent
                    {
                        // FIXME: This is redundant
                        if let Some(deps) = resource.dependencies {
                            for mut dep in deps {
                                if !self.clients.contains_key(&dep.type_) {
                                    dep.dependencies = self
                                        .clients
                                        .entry(dep.type_)
                                        // For handling clients required for dependent resources
                                        .or_insert(create_client(
                                            &resource.type_,
                                            &self.client_details,
                                            &self.config,
                                            self.dry_run,
                                        ))
                                        .dependencies(&dep)
                                        .await;
                                    done = done + 1; // newly created client does not send Shutdown event
                                } else {
                                    dep.dependencies = self
                                        .clients
                                        .get(&dep.type_)
                                        .unwrap()
                                        .dependencies(&dep)
                                        .await;
                                }
                                self.dag.add_node_to_dag(dep);
                            }
                        }
                    }
                }
                Event::Shutdown(_et) => {
                    done = done + 1;
                    if done == self.clients.keys().len() {
                        break;
                    }
                }
            }
        }
        if !is_dag(&self.dag.graph) {
            return Err(Error::Dag(
                "Failed constructing dependency graph of the resources".to_string(),
            ));
        }
        if let Some(dot) = self.dag.get_dot() {
            trace!("{}", dot);
        }
        Ok(())
    }
async fn build_dag ( & mut self ) -> Result < ( ) > { let mut done : usize = 0 ; while let Some ( r ) = self . rx . recv ( ) . await { match r { Event :: Resource ( resource ) => { self . dag . add_node_to_dag ( resource . clone ( ) ) ; if resource . enforcement_state == EnforcementState :: Delete || resource . enforcement_state == EnforcementState :: DeleteDependent { // FIXME: This is redundant if let Some ( deps ) = resource . dependencies { for mut dep in deps { if ! self . clients . contains_key ( & dep . type_ ) { dep . dependencies = self . clients . entry ( dep . type_ ) // For handling clients required for dependent resources . or_insert ( create_client ( & resource . type_ , & self . client_details , & self . config , self . dry_run , ) ) . dependencies ( & dep ) . await ; done = done + 1 ; // newly created client does not send Shutdown event } else { dep . dependencies = self . clients . get ( & dep . type_ ) . unwrap ( ) . dependencies ( & dep ) . await ; } self . dag . add_node_to_dag ( dep ) ; } } } } Event :: Shutdown ( _et ) => { done = done + 1 ; if done == self . clients . keys ( ) . len ( ) { break ; } } } } if ! is_dag ( & self . dag . graph ) { return Err ( Error :: Dag ( " " . to_string ( ) , ) ) ; } if let Some ( dot ) = self . dag . get_dot ( ) { trace ! ( " " dot ) ; } Ok ( ( ) ) }
Builds a dependency graph of resources
Builds a dependency graph of resources
&mut self