Skip to content

Commit 9a9dc2b

Browse files
committed
feat(MemStore): add GC option, impl new_with_opts
1 parent 7a1f14b commit 9a9dc2b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/store/mem.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ use crate::{
5858
},
5959
protocol::ChunkRangesExt,
6060
store::{
61+
gc::{run_gc, GcConfig},
6162
util::{SizeInfo, SparseMemFile, Tag},
6263
IROH_BLOCK_SIZE,
6364
},
@@ -66,7 +67,9 @@ use crate::{
6667
};
6768

6869
#[derive(Debug, Default)]
69-
pub struct Options {}
70+
pub struct Options {
71+
pub gc_config: Option<GcConfig>,
72+
}
7073

7174
#[derive(Debug, Clone)]
7275
#[repr(transparent)]
@@ -113,6 +116,10 @@ impl MemStore {
113116
}
114117

115118
pub fn new() -> Self {
119+
Self::new_with_opts(Options::default())
120+
}
121+
122+
pub fn new_with_opts(opts: Options) -> Self {
116123
let (sender, receiver) = tokio::sync::mpsc::channel(32);
117124
tokio::spawn(
118125
Actor {
@@ -130,7 +137,13 @@ impl MemStore {
130137
}
131138
.run(),
132139
);
133-
Self::from_sender(sender.into())
140+
141+
let store = Self::from_sender(sender.into());
142+
if let Some(gc_config) = opts.gc_config {
143+
tokio::spawn(run_gc(store.deref().clone(), gc_config));
144+
}
145+
146+
store
134147
}
135148
}
136149

0 commit comments

Comments
 (0)