/// Performs updates and executes hooks.
///
/// Returns `true` if the service was updated.
Performs updates and executes hooks.
Returns `true` if the service was updated.
Performs updates and executes hooks . Returns ` true ` if the service was updated .
pub fn tick(&mut self,
                census_ring: &CensusRing,
                launcher: &LauncherCli,
                executor: &TaskExecutor)
                -> bool {
        // We may need to block the service from starting until all
        // its binds are satisfied
        if !self.initialized {
            match self.binding_mode {
                BindingMode::Relaxed => (),
                BindingMode::Strict => {
                    self.validate_binds(census_ring);
                    if !self.unsatisfied_binds.is_empty() {
                        outputln!(preamble self.service_group, "Waiting for service binds...");
                        return false;
                    }
                }
            }
        }
        // Binds may become unsatisfied as a service is running (e.g.,
        // service members disappear, etc.) This can affect the data
        // we pass to templates, so we must account for it here.
        if census_ring.changed() {
            self.validate_binds(census_ring);
        }
        let svc_updated = self.update_templates(census_ring);
        if self.update_service_files(census_ring) {
            self.file_updated();
        }
        match self.topology {
            Topology::Standalone => {
                self.execute_hooks(launcher, executor);
            }
            Topology::Leader => {
                let census_group =
                    census_ring.census_group_for(&self.service_group)
                               .expect("Service Group's census entry missing from list!");
                match census_group.election_status {
                    ElectionStatus::None => {
                        if self.last_election_status != census_group.election_status {
                            outputln!(preamble self.service_group,
                                      "Waiting to execute hooks; election hasn't started");
                            self.last_election_status = census_group.election_status;
                        }
                    }
                    ElectionStatus::ElectionInProgress => {
                        if self.last_election_status != census_group.election_status {
                            outputln!(preamble self.service_group,
                                      "Waiting to execute hooks; election in progress.");
                            self.last_election_status = census_group.election_status;
                        }
                    }
                    ElectionStatus::ElectionNoQuorum => {
                        if self.last_election_status != census_group.election_status {
                            outputln!(preamble self.service_group,
                                      "Waiting to execute hooks; election in progress, \
                                      and we have no quorum.");
                            self.last_election_status = census_group.election_status
                        }
                    }
                    ElectionStatus::ElectionFinished => {
                        let leader_id = census_group.leader_id
                                                    .as_ref()
                                                    .expect("No leader with finished election");
                        if self.last_election_status != census_group.election_status {
                            outputln!(preamble self.service_group,
                                      "Executing hooks; {} is the leader",
                                      leader_id.to_string());
                            self.last_election_status = census_group.election_status;
                        }
                        self.execute_hooks(launcher, executor)
                    }
                }
            }
        }
        if svc_updated {
            // The intention here is to do a health check soon after a
            // service's configuration changes, as a way to (among
            // other things) detect potential impacts when bound
            // services change exported configuration.
            //
            // TODO (CM): Rather than restarting health checks
            // immediately (and correspondingly, immediately after a
            // service starts for the first time), should we instead
            // have an initial delay of X seconds, and _then_ start
            // the "normal" sequence of checks?
            self.restart_health_checks(executor);
        }
        svc_updated
    }
pub fn tick ( & mut self , census_ring : & CensusRing , launcher : & LauncherCli , executor : & TaskExecutor ) -> bool { // We may need to block the service from starting until all // its binds are satisfied if ! self . initialized { match self . binding_mode { BindingMode :: Relaxed => ( ) , BindingMode :: Strict => { self . validate_binds ( census_ring ) ; if ! self . unsatisfied_binds . is_empty ( ) { outputln ! ( preamble self service_group " " ) ; return false ; } } } } // Binds may become unsatisfied as a service is running (e.g., // service members disappear, etc.) This can affect the data // we pass to templates, so we must account for it here. if census_ring . changed ( ) { self . validate_binds ( census_ring ) ; } let svc_updated = self . update_templates ( census_ring ) ; if self . update_service_files ( census_ring ) { self . file_updated ( ) ; } match self . topology { Topology :: Standalone => { self . execute_hooks ( launcher , executor ) ; } Topology :: Leader => { let census_group = census_ring . census_group_for ( & self . service_group ) . expect ( " " ) ; match census_group . election_status { ElectionStatus :: None => { if self . last_election_status != census_group . election_status { outputln ! ( preamble self service_group " " ) ; self . last_election_status = census_group . election_status ; } } ElectionStatus :: ElectionInProgress => { if self . last_election_status != census_group . election_status { outputln ! ( preamble self service_group " " ) ; self . last_election_status = census_group . election_status ; } } ElectionStatus :: ElectionNoQuorum => { if self . last_election_status != census_group . election_status { outputln ! ( preamble self service_group " \
 " ) ; self . last_election_status = census_group . election_status } } ElectionStatus :: ElectionFinished => { let leader_id = census_group . leader_id . as_ref ( ) . expect ( " " ) ; if self . last_election_status != census_group . election_status { outputln ! ( preamble self service_group " " leader_id to_string ( ) ) ; self . last_election_status = census_group . election_status ; } self . execute_hooks ( launcher , executor ) } } } } if svc_updated { // The intention here is to do a health check soon after a // service's configuration changes, as a way to (among // other things) detect potential impacts when bound // services change exported configuration. // // TODO (CM): Rather than restarting health checks // immediately (and correspondingly, immediately after a // service starts for the first time), should we instead // have an initial delay of X seconds, and _then_ start // the "normal" sequence of checks? self . restart_health_checks ( executor ) ; } svc_updated }
Performs updates and executes hooks.
Performs updates and executes hooks .
&mut self
census_ring
&CensusRing
launcher
&LauncherCli
executor
&TaskExecutor