tracks lexicons and how many times they appeared on the jetstream

feat(server): actually make the block inserts start in parallel

ptr.pet 4c4a5aa3 fddb212c

verified
Changed files
+13 -16
server
src
db
+13 -16
server/src/db/mod.rs
···
drop(_guard);
// process the blocks
-
let mut blocks = Vec::with_capacity(data.len());
data.into_par_iter()
.map(|chunk| {
chunk
···
})
.collect::<Result<Vec<_>, _>>()
})
-
.collect_into_vec(&mut blocks);
-
-
// execute into db
-
for chunk in blocks.into_iter() {
-
let chunk = chunk?;
-
for (i, block, handle) in chunk {
-
self.sync_pool
-
.execute(move || match handle.insert(block.key, block.data) {
-
Ok(_) => {
-
tracing::info!("{}: [{i}] synced {}", block.written, handle.nsid())
-
}
-
Err(err) => tracing::error!("failed to sync block: {}", err),
-
});
-
}
-
}
+
.try_for_each(|chunk| {
+
let chunk = chunk?;
+
for (i, block, handle) in chunk {
+
self.sync_pool
+
.execute(move || match handle.insert(block.key, block.data) {
+
Ok(_) => {
+
tracing::info!("{}: [{i}] synced {}", block.written, handle.nsid())
+
}
+
Err(err) => tracing::error!("failed to sync block: {}", err),
+
});
+
}
+
AppResult::Ok(())
+
})?;
self.sync_pool.join();
Ok(())