Separated message functions.
This commit is contained in:
		@@ -270,24 +270,30 @@ impl Cache {
 | 
			
		||||
        Ok(Self { channel: channel })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn start(&self) {
 | 
			
		||||
        loop {
 | 
			
		||||
            match self.channel.recv().await.unwrap() {
 | 
			
		||||
                ToCache::Query(data) => {
 | 
			
		||||
                    for id in data.ids {
 | 
			
		||||
    async fn query(&self, qry: CacheQuery) {
 | 
			
		||||
        for id in qry.ids {
 | 
			
		||||
            if id == ENTRY {
 | 
			
		||||
                let mut holder = HashMap::new();
 | 
			
		||||
                holder.insert(ENTRY.to_string(), DataType::new("store"));
 | 
			
		||||
                            data.reply.send(FromCache::Data(holder)).await.unwrap();
 | 
			
		||||
                qry.reply.send(FromCache::Data(holder)).await.unwrap();
 | 
			
		||||
            } else {
 | 
			
		||||
                            data.reply
 | 
			
		||||
                qry.reply
 | 
			
		||||
                    .send(FromCache::Error(MTTError::new("fred")))
 | 
			
		||||
                    .await
 | 
			
		||||
                    .unwrap();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
                ToCache::Commit(data) => data.reply.send(FromCache::Ok).await.unwrap(),
 | 
			
		||||
 | 
			
		||||
    async fn commit(&self, commit: CacheCommit) {
 | 
			
		||||
        commit.reply.send(FromCache::Ok).await.unwrap();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async fn start(&self) {
 | 
			
		||||
        loop {
 | 
			
		||||
            match self.channel.recv().await.unwrap() {
 | 
			
		||||
                ToCache::Query(qry) => self.query(qry).await,
 | 
			
		||||
                ToCache::Commit(commit) => self.commit(commit).await,
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -363,6 +369,12 @@ mod caches {
 | 
			
		||||
            _ => assert!(false, "{:?} should have been an error.", result),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[async_std::test]
 | 
			
		||||
    async fn add_database_commit() {
 | 
			
		||||
        //let dir = tempdir().unwrap();
 | 
			
		||||
        //let s_cache = start_cache(dir.path()).await;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub async fn start_db<P>(_dir: P) -> Result<MoreThanText, MTTError>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user