Skip to content

Commit ac6f1bc

Browse files
author
Piotr Jastrzebski
committed
Expose push_batch_size config through Builder
Signed-off-by: Piotr Jastrzebski <[email protected]>
1 parent 95e6253 commit ac6f1bc

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

libsql/src/database/builder.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ impl Builder<()> {
107107
connector: None,
108108
read_your_writes: true,
109109
remote_writes: false,
110+
push_batch_size: 0,
110111
},
111112
}
112113
}
@@ -524,6 +525,7 @@ cfg_sync! {
524525
connector: Option<crate::util::ConnectorService>,
525526
remote_writes: bool,
526527
read_your_writes: bool,
528+
push_batch_size: u32,
527529
}
528530

529531
impl Builder<SyncedDatabase> {
@@ -543,6 +545,11 @@ cfg_sync! {
543545
self
544546
}
545547

548+
pub fn set_push_batch_size(mut self, v: u32) -> Builder<SyncedDatabase> {
549+
self.inner.push_batch_size = v;
550+
self
551+
}
552+
546553
/// Provide a custom http connector that will be used to create http connections.
547554
pub fn connector<C>(mut self, connector: C) -> Builder<SyncedDatabase>
548555
where
@@ -570,6 +577,7 @@ cfg_sync! {
570577
connector,
571578
remote_writes,
572579
read_your_writes,
580+
push_batch_size,
573581
} = self.inner;
574582

575583
let path = path.to_str().ok_or(crate::Error::InvalidUTF8Path)?.to_owned();
@@ -596,6 +604,10 @@ cfg_sync! {
596604
)
597605
.await?;
598606

607+
if push_batch_size > 0 {
608+
db.sync_ctx.as_ref().unwrap().lock().await.set_push_batch_size(push_batch_size);
609+
}
610+
599611
Ok(Database {
600612
db_type: DbType::Offline {
601613
db,

libsql/src/sync.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ impl SyncContext {
120120
Ok(me)
121121
}
122122

123+
pub fn set_push_batch_size(&mut self, push_batch_size: u32) {
124+
self.push_batch_size = push_batch_size;
125+
}
126+
123127
#[tracing::instrument(skip(self))]
124128
pub(crate) async fn pull_one_frame(
125129
&mut self,

0 commit comments

Comments
 (0)