aboutsummaryrefslogtreecommitdiff
path: root/src/table/table.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-12-14 12:28:07 +0100
committerAlex Auvolat <alex@adnab.me>2022-12-14 12:28:07 +0100
commit2183518edccadef47cdeaf6476033b52d8832d6e (patch)
tree8a7d0ce0a622bd512ad6138a90f4bb4604bc38fb /src/table/table.rs
parent83c8467e23c1f531ae233766d5dc7244afe57f08 (diff)
downloadgarage-2183518edccadef47cdeaf6476033b52d8832d6e.tar.gz
garage-2183518edccadef47cdeaf6476033b52d8832d6e.zip
Spawn all background workers in a separate step
Diffstat (limited to 'src/table/table.rs')
-rw-r--r--src/table/table.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/table/table.rs b/src/table/table.rs
index c8e0576e..cb200ef2 100644
--- a/src/table/table.rs
+++ b/src/table/table.rs
@@ -36,6 +36,7 @@ pub struct Table<F: TableSchema + 'static, R: TableReplication + 'static> {
pub data: Arc<TableData<F, R>>,
pub merkle_updater: Arc<MerkleUpdater<F, R>>,
pub syncer: Arc<TableSyncer<F, R>>,
+ gc: Arc<TableGc<F, R>>,
endpoint: Arc<Endpoint<TableRpc<F>, Self>>,
}
@@ -76,29 +77,34 @@ where
let data = TableData::new(system.clone(), instance, replication, db);
- let merkle_updater = MerkleUpdater::launch(&system.background, data.clone());
+ let merkle_updater = MerkleUpdater::new(data.clone());
- let syncer = TableSyncer::launch(system.clone(), data.clone(), merkle_updater.clone());
- TableGc::launch(system.clone(), data.clone());
+ let syncer = TableSyncer::new(system.clone(), data.clone(), merkle_updater.clone());
+ let gc = TableGc::new(system.clone(), data.clone());
let table = Arc::new(Self {
system,
data,
merkle_updater,
+ gc,
syncer,
endpoint,
});
- table
- .system
- .background
- .spawn_worker(InsertQueueWorker(table.clone()));
-
table.endpoint.set_handler(table.clone());
table
}
+ pub fn spawn_workers(self: &Arc<Self>) {
+ self.merkle_updater.spawn_workers(&self.system.background);
+ self.syncer.spawn_workers();
+ self.gc.spawn_workers();
+ self.system
+ .background
+ .spawn_worker(InsertQueueWorker(self.clone()));
+ }
+
pub async fn insert(&self, e: &F::E) -> Result<(), Error> {
let tracer = opentelemetry::global::tracer("garage_table");
let span = tracer.start(format!("{} insert", F::TABLE_NAME));