/// Restore the dispatcher from the state which was saved in the specified snapshot.
///
/// # Panics
///
/// This method panics if the stored state cannot be restored.
Restore the dispatcher from the state which was saved in the specified snapshot.
Restore the dispatcher from the state which was saved in the specified snapshot .
pub(crate) fn restore_state(&mut self, snapshot: &dyn Snapshot) {
        let schema = Schema::new(snapshot);
        // Restore information about the deployed services.
        for (artifact, state) in schema.artifacts().iter() {
            debug_assert_eq!(
                state.status,
                ArtifactStatus::Active,
                "BUG: Artifact should not be in pending state."
            );
            self.deploy_artifact(artifact.clone(), state.deploy_spec)
                .wait()
                .unwrap_or_else(|err| {
                    panic!(
                        "BUG: Can't restore state, artifact {:?} has not been deployed now, \
                         but was deployed previously. Reported error: {}",
                        artifact, err
                    );
                });
        }
        // Restart active service instances.
        for state in schema.instances().values() {
            let data_version = state.data_version().to_owned();
            let status = state
                .status
                .expect("BUG: Stored service instance should have a determined status.");
            self.update_service_status(snapshot, &state.spec, status.clone());
            // Restart a migration script if it is not finished locally.
            if let Some(target) = status.ongoing_migration_target() {
                if schema.local_migration_result(&state.spec.name).is_none() {
                    self.start_migration_script(target, state.spec, data_version);
                }
            }
        }
        // Notify runtimes about the end of initialization process.
        for runtime in self.runtimes.values_mut() {
            runtime.on_resume();
        }
    }
pub ( crate ) fn restore_state ( & mut self , snapshot : & dyn Snapshot ) { let schema = Schema :: new ( snapshot ) ; // Restore information about the deployed services. for ( artifact , state ) in schema . artifacts ( ) . iter ( ) { debug_assert_eq ! ( state status ArtifactStatus Active " " ) ; self . deploy_artifact ( artifact . clone ( ) , state . deploy_spec ) . wait ( ) . unwrap_or_else ( | err | { panic ! ( " \
 " artifact err ) ; } ) ; } // Restart active service instances. for state in schema . instances ( ) . values ( ) { let data_version = state . data_version ( ) . to_owned ( ) ; let status = state . status . expect ( " " ) ; self . update_service_status ( snapshot , & state . spec , status . clone ( ) ) ; // Restart a migration script if it is not finished locally. if let Some ( target ) = status . ongoing_migration_target ( ) { if schema . local_migration_result ( & state . spec . name ) . is_none ( ) { self . start_migration_script ( target , state . spec , data_version ) ; } } } // Notify runtimes about the end of initialization process. for runtime in self . runtimes . values_mut ( ) { runtime . on_resume ( ) ; } }
Restore the dispatcher from the state which was saved in the specified snapshot.
Restore the dispatcher from the state which was saved in the specified snapshot .
&mut self
snapshot
&dyn Snapshot
panics
This method panics if the stored state cannot be restored.
This method panics if the stored state cannot be restored .