Skip to content

Commit 566664e

Browse files
committed
fmt
1 parent 4b5baac commit 566664e

8 files changed

Lines changed: 33 additions & 30 deletions

File tree

bottomless/src/replicator.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,8 @@ impl Replicator {
14551455
4096,
14561456
libsql_sys::connection::NO_AUTOCHECKPOINT,
14571457
encryption_config,
1458-
).await?;
1458+
)
1459+
.await?;
14591460
let prefix = format!("{}-{}/", self.db_name, generation);
14601461
let mut page_buf = {
14611462
let mut v = Vec::with_capacity(page_size);

libsql-replication/src/injector/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub type Result<T, E=Error> = std::result::Result<T, E>;
1+
pub type Result<T, E = Error> = std::result::Result<T, E>;
22
pub type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;
33

44
#[derive(Debug, thiserror::Error)]

libsql-replication/src/injector/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use std::future::Future;
22

3-
pub use sqlite_injector::SqliteInjector;
43
pub use libsql_injector::LibsqlInjector;
4+
pub use sqlite_injector::SqliteInjector;
55

66
use crate::frame::{Frame, FrameNo};
77

8-
use error::Result;
98
pub use error::Error;
9+
use error::Result;
1010

1111
mod error;
12-
mod sqlite_injector;
1312
mod libsql_injector;
13+
mod sqlite_injector;
1414

1515
pub trait Injector {
1616
/// Inject a singular frame.

libsql-replication/src/injector/sqlite_injector/mod.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,23 @@ pub struct SqliteInjector {
2525
}
2626

2727
impl Injector for SqliteInjector {
28-
async fn inject_frame(
29-
&mut self,
30-
frame: Frame,
31-
) -> Result<Option<FrameNo>> {
28+
async fn inject_frame(&mut self, frame: Frame) -> Result<Option<FrameNo>> {
3229
let inner = self.inner.clone();
33-
spawn_blocking(move || {
34-
inner.lock().inject_frame(frame)
35-
}).await.unwrap()
30+
spawn_blocking(move || inner.lock().inject_frame(frame))
31+
.await
32+
.unwrap()
3633
}
3734

3835
async fn rollback(&mut self) {
3936
let inner = self.inner.clone();
40-
spawn_blocking(move || {
41-
inner.lock().rollback()
42-
}).await.unwrap();
37+
spawn_blocking(move || inner.lock().rollback())
38+
.await
39+
.unwrap();
4340
}
4441

4542
async fn flush(&mut self) -> Result<Option<FrameNo>> {
4643
let inner = self.inner.clone();
47-
spawn_blocking(move || {
48-
inner.lock().flush()
49-
}).await.unwrap()
44+
spawn_blocking(move || inner.lock().flush()).await.unwrap()
5045
}
5146
}
5247

@@ -56,13 +51,15 @@ impl SqliteInjector {
5651
capacity: usize,
5752
auto_checkpoint: u32,
5853
encryption_config: Option<libsql_sys::EncryptionConfig>,
59-
) ->super::Result<Self> {
54+
) -> super::Result<Self> {
6055
let inner = spawn_blocking(move || {
6156
SqliteInjectorInner::new(path, capacity, auto_checkpoint, encryption_config)
62-
}).await.unwrap()?;
57+
})
58+
.await
59+
.unwrap()?;
6360

6461
Ok(Self {
65-
inner: Arc::new(Mutex::new(inner))
62+
inner: Arc::new(Mutex::new(inner)),
6663
})
6764
}
6865
}
@@ -278,7 +275,8 @@ mod test {
278275
fn test_simple_inject_frames() {
279276
let temp = tempfile::tempdir().unwrap();
280277

281-
let mut injector = SqliteInjectorInner::new(temp.path().join("data"), 10, 10000, None).unwrap();
278+
let mut injector =
279+
SqliteInjectorInner::new(temp.path().join("data"), 10, 10000, None).unwrap();
282280
let log = wal_log();
283281
for frame in log {
284282
injector.inject_frame(frame).unwrap();
@@ -298,7 +296,8 @@ mod test {
298296
let temp = tempfile::tempdir().unwrap();
299297

300298
// inject one frame at a time
301-
let mut injector = SqliteInjectorInner::new(temp.path().join("data"), 1, 10000, None).unwrap();
299+
let mut injector =
300+
SqliteInjectorInner::new(temp.path().join("data"), 1, 10000, None).unwrap();
302301
let log = wal_log();
303302
for frame in log {
304303
injector.inject_frame(frame).unwrap();
@@ -318,7 +317,8 @@ mod test {
318317
let temp = tempfile::tempdir().unwrap();
319318

320319
// inject one frame at a time
321-
let mut injector = SqliteInjectorInner::new(temp.path().join("data"), 10, 1000, None).unwrap();
320+
let mut injector =
321+
SqliteInjectorInner::new(temp.path().join("data"), 10, 1000, None).unwrap();
322322
let mut frames = wal_log();
323323

324324
assert!(injector

libsql-replication/src/replicator.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ where
168168
auto_checkpoint,
169169
encryption_config,
170170
)
171-
.await?;
171+
.await?;
172172

173173
Ok(Self::new(client, injector))
174174
}
@@ -179,7 +179,6 @@ where
179179
C: ReplicatorClient,
180180
I: Injector,
181181
{
182-
183182
pub fn new(client: C, injector: I) -> Self {
184183
Self {
185184
client,

libsql-replication/src/rpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub mod replication {
5151
pub fn new(wal_flavor: WalFlavor) -> Self {
5252
Self {
5353
handshake_version: Some(1),
54-
wal_flavor: Some(wal_flavor.into())
54+
wal_flavor: Some(wal_flavor.into()),
5555
}
5656
}
5757
}

libsql-server/src/rpc/replication_log.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use bytes::Bytes;
77
use chrono::{DateTime, Utc};
88
use futures::stream::BoxStream;
99
use futures_core::Future;
10-
use libsql_replication::rpc::replication::hello_request::WalFlavor;
1110
pub use libsql_replication::rpc::replication as rpc;
11+
use libsql_replication::rpc::replication::hello_request::WalFlavor;
1212
use libsql_replication::rpc::replication::replication_log_server::ReplicationLog;
1313
use libsql_replication::rpc::replication::{
1414
Frame, Frames, HelloRequest, HelloResponse, LogOffset, NAMESPACE_DOESNT_EXIST,
@@ -357,7 +357,7 @@ impl ReplicationLog for ReplicationLogService {
357357
}
358358

359359
if let WalFlavor::Libsql = req.get_ref().wal_flavor() {
360-
return Err(Status::invalid_argument("libsql wal not supported"))
360+
return Err(Status::invalid_argument("libsql wal not supported"));
361361
}
362362

363363
let (logger, config, version, _, _) =

libsql-wal/src/replication/injector.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ mod test {
9494

9595
let mut tx = crate::transaction::Transaction::Read(replica_shared.begin_read(42));
9696
replica_shared.upgrade(&mut tx).unwrap();
97-
let guard = tx.into_write().unwrap_or_else(|_| panic!()).into_lock_owned();
97+
let guard = tx
98+
.into_write()
99+
.unwrap_or_else(|_| panic!())
100+
.into_lock_owned();
98101
let mut injector = Injector::new(replica_shared.clone(), guard, 10).unwrap();
99102

100103
primary_conn.execute("create table test (x)", ()).unwrap();

0 commit comments

Comments
 (0)