/// Panics if any introspection source id is not a system id
Panics if any introspection source id is not a system id
Panics if any introspection source id is not a system id
pub fn insert_compute_instance(
        &mut self,
        cluster_name: &str,
        config: &Option<ComputeInstanceIntrospectionConfig>,
        introspection_sources: &Vec<(&'static BuiltinLog, GlobalId)>,
    ) -> Result<ComputeInstanceId, Error> {
        let config = serde_json::to_string(config)
            .map_err(|err| Error::from(StashError::from(err.to_string())))?;
        let id = match self.compute_instances.insert(
            |id| ComputeInstanceKey { id: id.unwrap() },
            ComputeInstanceValue {
                name: cluster_name.to_string(),
                config: Some(config),
            },
        ) {
            Ok(id) => id.unwrap(),
            Err(()) => {
                return Err(Error::new(ErrorKind::ClusterAlreadyExists(
                    cluster_name.to_owned(),
                )))
            }
        };
        for (builtin, index_id) in introspection_sources {
            let index_id = if let GlobalId::System(id) = index_id {
                *id
            } else {
                panic!("non-system id provided")
            };
            self.introspection_sources
                .insert(
                    |_| ComputeIntrospectionSourceIndexKey {
                        compute_id: id,
                        name: builtin.name.to_string(),
                    },
                    ComputeIntrospectionSourceIndexValue { index_id },
                )
                .expect("no uniqueness violation");
        }
        Ok(id)
    }
pub fn insert_compute_instance ( & mut self , cluster_name : & str , config : & Option < ComputeInstanceIntrospectionConfig > , introspection_sources : & Vec < ( & ' static BuiltinLog , GlobalId ) > , ) -> Result < ComputeInstanceId , Error > { let config = serde_json :: to_string ( config ) . map_err ( | err | Error :: from ( StashError :: from ( err . to_string ( ) ) ) ) ? ; let id = match self . compute_instances . insert ( | id | ComputeInstanceKey { id : id . unwrap ( ) } , ComputeInstanceValue { name : cluster_name . to_string ( ) , config : Some ( config ) , } , ) { Ok ( id ) => id . unwrap ( ) , Err ( ( ) ) => { return Err ( Error :: new ( ErrorKind :: ClusterAlreadyExists ( cluster_name . to_owned ( ) , ) ) ) } } ; for ( builtin , index_id ) in introspection_sources { let index_id = if let GlobalId :: System ( id ) = index_id { * id } else { panic ! ( " " ) } ; self . introspection_sources . insert ( | _ | ComputeIntrospectionSourceIndexKey { compute_id : id , name : builtin . name . to_string ( ) , } , ComputeIntrospectionSourceIndexValue { index_id } , ) . expect ( " " ) ; } Ok ( id ) }
Panics if any introspection source id is not a system id
Panics if any introspection source id is not a system id
&mut self
cluster_name
&str
config
&Option<ComputeInstanceIntrospectionConfig>
introspection_sources
&Vec<(&'static BuiltinLog, GlobalId)>