0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-06-01 09:52:45 +00:00

pass Storage as Arc to registry

This commit is contained in:
ad hoc
2024-08-23 21:26:59 +02:00
parent 17b284ad25
commit 4797b3bd37
6 changed files with 10 additions and 9 deletions
libsql-server/src
libsql-wal

@ -821,7 +821,7 @@ where
) -> anyhow::Result<(NamespaceConfigurators, MakeReplicationSvc)> {
tracing::info!("using libsql wal");
let (sender, receiver) = tokio::sync::mpsc::channel(64);
let storage = if let Some(ref opt) = self.db_config.bottomless_replication {
let storage: Arc<_> = if let Some(ref opt) = self.db_config.bottomless_replication {
if client_config.is_some() {
anyhow::bail!("bottomless cannot be enabled on replicas");
}
@ -865,9 +865,10 @@ where
Either::A(storage)
} else {
Either::B(NoStorage)
}.into();
};
if self.rpc_server_config.is_some() && matches!(storage, Either::B(_)) {
if self.rpc_server_config.is_some() && matches!(*storage, Either::B(_)) {
anyhow::bail!("replication without bottomless not supported yet");
}

@ -99,7 +99,7 @@ where
match &cli.subcommand {
Subcommand::Shell { db_path } => {
let (sender, receiver) = tokio::sync::mpsc::channel(64);
let registry = Arc::new(WalRegistry::new(db_path.clone(), storage, sender).unwrap());
let registry = Arc::new(WalRegistry::new(db_path.clone(), storage.into(), sender).unwrap());
let checkpointer = LibsqlCheckpointer::new(registry.clone(), receiver, 64);
join_set.spawn(checkpointer.run());
run_shell(

@ -99,7 +99,7 @@ pub mod test {
WalRegistry::new_with_io(
io.clone(),
tmp.path().join("test/wals"),
TestStorage::new_io(store, io),
TestStorage::new_io(store, io).into(),
sender,
)
.unwrap(),

@ -47,7 +47,7 @@ pub struct WalRegistry<IO: Io, S> {
impl<S> WalRegistry<StdIO, S> {
pub fn new(
path: PathBuf,
storage: S,
storage: Arc<S>,
checkpoint_notifier: mpsc::Sender<CheckpointMessage>,
) -> Result<Self> {
Self::new_with_io(StdIO(()), path, storage, checkpoint_notifier)
@ -58,7 +58,7 @@ impl<IO: Io, S> WalRegistry<IO, S> {
pub fn new_with_io(
io: IO,
path: PathBuf,
storage: S,
storage: Arc<S>,
checkpoint_notifier: mpsc::Sender<CheckpointMessage>,
) -> Result<Self> {
io.create_dir_all(&path)?;
@ -67,7 +67,7 @@ impl<IO: Io, S> WalRegistry<IO, S> {
path,
opened: Default::default(),
shutdown: Default::default(),
storage: storage.into(),
storage,
checkpoint_notifier,
};

@ -213,7 +213,7 @@ async fn flaky_fs() {
WalRegistry::new_with_io(
io.clone(),
tmp.path().join("test/wals"),
TestStorage::new_io(false, io),
TestStorage::new_io(false, io).into(),
sender,
)
.unwrap(),

@ -94,7 +94,7 @@ async fn run_test_sample(path: &Path) -> Result {
let (sender, _receiver) = tokio::sync::mpsc::channel(64);
let registry = Arc::new(
WalRegistry::new(tmp.path().join("test/wals"), TestStorage::new(), sender).unwrap(),
WalRegistry::new(tmp.path().join("test/wals"), TestStorage::new().into(), sender).unwrap(),
);
let wal_manager = LibsqlWalManager::new(registry.clone(), Arc::new(resolver));
let db_path = tmp.path().join("test/data").clone();