pub fn activate(
        &mut self,
        activate_request: Result<ActivateRequest, serde_json::Error>,
    ) -> ActivateResponse {
        if let Err(e) = activate_request {
            return ActivateResponse {
                result: ActivationStatus::InvalidRequest,
                dbg_message: e.to_string(),
            };
        }

        // This is a safe unwrap, since we just checked if activate_request was in an error state
        let activate_request = activate_request.unwrap();

        if self.active_components.contains_key(&activate_request.id.path) {
            warn!(
                "Attempt to activate already activated component ({:?}) was foiled!",
                activate_request
            );
            return ActivateResponse {
                result: ActivationStatus::AlreadyRunning,
                dbg_message: "already running, redundant request!!".to_string(),
            };
        }

        let isolated_process_wrapper = match IsolatedProcessWrapper::new(activate_request.clone()) {
            Ok(w) => w,
            Err(e) => {
                return ActivateResponse {
                    result: ActivationStatus::FailedToStart,
                    dbg_message: e.to_string(),
                }
            }
        };

        self.active_components.insert(
            activate_request.id.path.clone(),
            Mutex::new(ComponentHandle {
                id: activate_request.id.clone(),
                component_process_wrapper: isolated_process_wrapper,
                log_tracker: LogTracker::new(),
                stat_tracker: StatTracker::default(),
            }),
        );

        info!("Successfully activated a component ({:?})", activate_request);

        ActivateResponse {
            result: ActivationStatus::ActivationSuccessful,
            dbg_message: "successfully activated".to_string(),
        }
    }
// TODO: Activate and Deactivate should respect the hash passsed in, instead of blindly deactivating anything
Activate and Deactivate should respect the hash passsed in, instead of blindly deactivating anything
Activate and Deactivate should respect the hash passsed in instead of blindly deactivating anything
pub fn activate(
        &mut self,
        activate_request: Result<ActivateRequest, serde_json::Error>,
    ) -> ActivateResponse {
        if let Err(e) = activate_request {
            return ActivateResponse {
                result: ActivationStatus::InvalidRequest,
                dbg_message: e.to_string(),
            };
        }
        // This is a safe unwrap, since we just checked if activate_request was in an error state
        let activate_request = activate_request.unwrap();
        if self.active_components.contains_key(&activate_request.id.path) {
            warn!(
                "Attempt to activate already activated component ({:?}) was foiled!",
                activate_request
            );
            return ActivateResponse {
                result: ActivationStatus::AlreadyRunning,
                dbg_message: "already running, redundant request!!".to_string(),
            };
        }
        let isolated_process_wrapper = match IsolatedProcessWrapper::new(activate_request.clone()) {
            Ok(w) => w,
            Err(e) => {
                return ActivateResponse {
                    result: ActivationStatus::FailedToStart,
                    dbg_message: e.to_string(),
                }
            }
        };
        self.active_components.insert(
            activate_request.id.path.clone(),
            Mutex::new(ComponentHandle {
                id: activate_request.id.clone(),
                component_process_wrapper: isolated_process_wrapper,
                log_tracker: LogTracker::new(),
                stat_tracker: StatTracker::default(),
            }),
        );
        info!("Successfully activated a component ({:?})", activate_request);
        ActivateResponse {
            result: ActivationStatus::ActivationSuccessful,
            dbg_message: "successfully activated".to_string(),
        }
    }
pub fn activate ( & mut self , activate_request : Result < ActivateRequest , serde_json :: Error > , ) -> ActivateResponse { if let Err ( e ) = activate_request { return ActivateResponse { result : ActivationStatus :: InvalidRequest , dbg_message : e . to_string ( ) , } ; } // This is a safe unwrap, since we just checked if activate_request was in an error state let activate_request = activate_request . unwrap ( ) ; if self . active_components . contains_key ( & activate_request . id . path ) { warn ! ( " " activate_request ) ; return ActivateResponse { result : ActivationStatus :: AlreadyRunning , dbg_message : " " . to_string ( ) , } ; } let isolated_process_wrapper = match IsolatedProcessWrapper :: new ( activate_request . clone ( ) ) { Ok ( w ) => w , Err ( e ) => { return ActivateResponse { result : ActivationStatus :: FailedToStart , dbg_message : e . to_string ( ) , } } } ; self . active_components . insert ( activate_request . id . path . clone ( ) , Mutex :: new ( ComponentHandle { id : activate_request . id . clone ( ) , component_process_wrapper : isolated_process_wrapper , log_tracker : LogTracker :: new ( ) , stat_tracker : StatTracker :: default ( ) , } ) , ) ; info ! ( " " activate_request ) ; ActivateResponse { result : ActivationStatus :: ActivationSuccessful , dbg_message : " " . to_string ( ) , } }
TODO: Activate and Deactivate should respect the hash passsed in, instead of blindly deactivating anything
TODO : Activate and Deactivate should respect the hash passsed in instead of blindly deactivating anything
&mut self
activate_request
Result<ActivateRequest, serde_json::Error>
&mut self
activate_request
Result<ActivateRequest, serde_json::Error>