Skip to content

Commit 4797b3b

Browse files
committed
pass Storage as Arc to registry
1 parent 17b284a commit 4797b3b

6 files changed

Lines changed: 10 additions & 9 deletions

File tree

libsql-server/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ where
821821
) -> anyhow::Result<(NamespaceConfigurators, MakeReplicationSvc)> {
822822
tracing::info!("using libsql wal");
823823
let (sender, receiver) = tokio::sync::mpsc::channel(64);
824-
let storage = if let Some(ref opt) = self.db_config.bottomless_replication {
824+
let storage: Arc<_> = if let Some(ref opt) = self.db_config.bottomless_replication {
825825
if client_config.is_some() {
826826
anyhow::bail!("bottomless cannot be enabled on replicas");
827827
}
@@ -865,9 +865,10 @@ where
865865
Either::A(storage)
866866
} else {
867867
Either::B(NoStorage)
868+
}.into();
868869
};
869870

870-
if self.rpc_server_config.is_some() && matches!(storage, Either::B(_)) {
871+
if self.rpc_server_config.is_some() && matches!(*storage, Either::B(_)) {
871872
anyhow::bail!("replication without bottomless not supported yet");
872873
}
873874

libsql-wal/src/bins/shell/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ where
9999
match &cli.subcommand {
100100
Subcommand::Shell { db_path } => {
101101
let (sender, receiver) = tokio::sync::mpsc::channel(64);
102-
let registry = Arc::new(WalRegistry::new(db_path.clone(), storage, sender).unwrap());
102+
let registry = Arc::new(WalRegistry::new(db_path.clone(), storage.into(), sender).unwrap());
103103
let checkpointer = LibsqlCheckpointer::new(registry.clone(), receiver, 64);
104104
join_set.spawn(checkpointer.run());
105105
run_shell(

libsql-wal/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub mod test {
9999
WalRegistry::new_with_io(
100100
io.clone(),
101101
tmp.path().join("test/wals"),
102-
TestStorage::new_io(store, io),
102+
TestStorage::new_io(store, io).into(),
103103
sender,
104104
)
105105
.unwrap(),

libsql-wal/src/registry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub struct WalRegistry<IO: Io, S> {
4747
impl<S> WalRegistry<StdIO, S> {
4848
pub fn new(
4949
path: PathBuf,
50-
storage: S,
50+
storage: Arc<S>,
5151
checkpoint_notifier: mpsc::Sender<CheckpointMessage>,
5252
) -> Result<Self> {
5353
Self::new_with_io(StdIO(()), path, storage, checkpoint_notifier)
@@ -58,7 +58,7 @@ impl<IO: Io, S> WalRegistry<IO, S> {
5858
pub fn new_with_io(
5959
io: IO,
6060
path: PathBuf,
61-
storage: S,
61+
storage: Arc<S>,
6262
checkpoint_notifier: mpsc::Sender<CheckpointMessage>,
6363
) -> Result<Self> {
6464
io.create_dir_all(&path)?;
@@ -67,7 +67,7 @@ impl<IO: Io, S> WalRegistry<IO, S> {
6767
path,
6868
opened: Default::default(),
6969
shutdown: Default::default(),
70-
storage: storage.into(),
70+
storage,
7171
checkpoint_notifier,
7272
};
7373

libsql-wal/tests/flaky_fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ async fn flaky_fs() {
213213
WalRegistry::new_with_io(
214214
io.clone(),
215215
tmp.path().join("test/wals"),
216-
TestStorage::new_io(false, io),
216+
TestStorage::new_io(false, io).into(),
217217
sender,
218218
)
219219
.unwrap(),

libsql-wal/tests/oracle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async fn run_test_sample(path: &Path) -> Result {
9494

9595
let (sender, _receiver) = tokio::sync::mpsc::channel(64);
9696
let registry = Arc::new(
97-
WalRegistry::new(tmp.path().join("test/wals"), TestStorage::new(), sender).unwrap(),
97+
WalRegistry::new(tmp.path().join("test/wals"), TestStorage::new().into(), sender).unwrap(),
9898
);
9999
let wal_manager = LibsqlWalManager::new(registry.clone(), Arc::new(resolver));
100100
let db_path = tmp.path().join("test/data").clone();

0 commit comments

Comments
 (0)