Skip to content

Commit

Permalink
Generate Eitherxx variants (#1438)
Browse files Browse the repository at this point in the history
* Create a drop in replacement for `Either` with `Any`

* generate Eitherxx variants

* generate Eitherxx variants

---------

Co-authored-by: ad hoc <[email protected]>
  • Loading branch information
avinassh and MarinPostma authored Jun 4, 2024
1 parent 3460edc commit 07a679e
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 238 deletions.
1 change: 0 additions & 1 deletion libsql-server/src/connection/connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use super::libsql::Connection;
use super::TXN_TIMEOUT;

pub type ConnId = u64;

pub type InnerWalManager = Either<Sqlite3WalManager, LibsqlWalManager<StdIO>>;
pub type InnerWal = Either<Sqlite3Wal, LibsqlWal<StdIO>>;
pub type ManagedConnectionWal = WrappedWal<ManagedConnectionWalWrapper, InnerWal>;
Expand Down
12 changes: 6 additions & 6 deletions libsql-server/src/connection/libsql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl LibSqlConnection<libsql_sys::wal::wrapper::PassthroughWalWrapper> {
Default::default(),
Arc::new(|_| unreachable!()),
ConnectionManager::new(TXN_TIMEOUT),
Arc::new(|| Either::Left(Sqlite3WalManager::default())),
Arc::new(|| Either::A(Sqlite3WalManager::default())),
)
.await
.unwrap()
Expand Down Expand Up @@ -769,7 +769,7 @@ mod test {
None,
Default::default(),
Arc::new(|_| unreachable!()),
Arc::new(|| Either::Left(Sqlite3WalManager::default())),
Arc::new(|| Either::A(Sqlite3WalManager::default())),
)
.await
.unwrap();
Expand Down Expand Up @@ -816,7 +816,7 @@ mod test {
None,
Default::default(),
Arc::new(|_| unreachable!()),
Arc::new(|| Either::Left(Sqlite3WalManager::default())),
Arc::new(|| Either::A(Sqlite3WalManager::default())),
)
.await
.unwrap();
Expand Down Expand Up @@ -867,7 +867,7 @@ mod test {
None,
Default::default(),
Arc::new(|_| unreachable!()),
Arc::new(|| Either::Left(Sqlite3WalManager::default())),
Arc::new(|| Either::A(Sqlite3WalManager::default())),
)
.await
.unwrap();
Expand Down Expand Up @@ -952,7 +952,7 @@ mod test {
None,
Default::default(),
Arc::new(|_| unreachable!()),
Arc::new(|| Either::Left(Sqlite3WalManager::default())),
Arc::new(|| Either::A(Sqlite3WalManager::default())),
)
.await
.unwrap();
Expand Down Expand Up @@ -1038,7 +1038,7 @@ mod test {
None,
Default::default(),
Arc::new(|_| unreachable!()),
Arc::new(|| Either::Left(Sqlite3WalManager::default())),
Arc::new(|| Either::A(Sqlite3WalManager::default())),
)
.await
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions libsql-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,11 @@ where
});

tracing::info!("using libsql wal");
Ok((Arc::new(move || Either::Right(wal.clone())), shutdown_fut))
Ok((Arc::new(move || Either::B(wal.clone())), shutdown_fut))
} else {
tracing::info!("using sqlite3 wal");
Ok((
Arc::new(|| Either::Left(Sqlite3WalManager::default())),
Arc::new(|| Either::A(Sqlite3WalManager::default())),
Box::pin(ready(Ok(()))),
))
}
Expand Down
2 changes: 1 addition & 1 deletion libsql-server/src/schema/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ mod test {
bottomless_replication: None,
scripted_backup: None,
migration_scheduler,
make_wal_manager: Arc::new(|| Either::Left(Sqlite3WalManager::default())),
make_wal_manager: Arc::new(|| Either::A(Sqlite3WalManager::default())),
}
}

Expand Down
Loading

0 comments on commit 07a679e

Please sign in to comment.