aboutsummaryrefslogtreecommitdiff
path: root/src/object_table.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-12 13:03:55 +0200
committerAlex Auvolat <alex@adnab.me>2020-04-12 13:03:55 +0200
commit5967c5a5af430855fbd73f380041d63bd82f5ce1 (patch)
tree2e0063e418e2f93c56402570b341506691716239 /src/object_table.rs
parent419c70e50613faf5b450b9555aec32cb19226153 (diff)
downloadgarage-5967c5a5af430855fbd73f380041d63bd82f5ce1.tar.gz
garage-5967c5a5af430855fbd73f380041d63bd82f5ce1.zip
Refactor a bit
Diffstat (limited to 'src/object_table.rs')
-rw-r--r--src/object_table.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/object_table.rs b/src/object_table.rs
index 63dabf20..8ce49565 100644
--- a/src/object_table.rs
+++ b/src/object_table.rs
@@ -1,11 +1,10 @@
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
-use tokio::sync::RwLock;
use crate::data::*;
-use crate::server::Garage;
use crate::table::*;
+use crate::background::BackgroundRunner;
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
pub struct Object {
@@ -88,7 +87,8 @@ impl Entry<String, String> for Object {
}
pub struct ObjectTable {
- pub garage: RwLock<Option<Arc<Garage>>>,
+ pub background: Arc<BackgroundRunner>,
+ pub version_table: Arc<Table<VersionTable>>,
}
#[async_trait]
@@ -98,8 +98,8 @@ impl TableFormat for ObjectTable {
type E = Object;
async fn updated(&self, old: Option<Self::E>, new: Self::E) {
- let garage = self.garage.read().await.as_ref().cloned().unwrap();
- garage.clone().background.spawn(async move {
+ let version_table = self.version_table.clone();
+ self.background.spawn(async move {
// Propagate deletion of old versions
if let Some(old_v) = old {
for v in old_v.versions.iter() {
@@ -115,7 +115,7 @@ impl TableFormat for ObjectTable {
bucket: old_v.bucket.clone(),
key: old_v.key.clone(),
};
- garage.version_table.insert(&deleted_version).await?;
+ version_table.insert(&deleted_version).await?;
}
}
}