Skip to content

Commit 95e6253

Browse files
author
Piotr Jastrzebski
committed
Add push_batch_size to SyncContext
Signed-off-by: Piotr Jastrzebski <[email protected]>
1 parent 358240c commit 95e6253

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libsql/src/sync.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub mod transaction;
1919
const METADATA_VERSION: u32 = 0;
2020

2121
const DEFAULT_MAX_RETRIES: usize = 5;
22+
const DEFAULT_PUSH_BATCH_SIZE: u32 = 128;
2223

2324
#[derive(thiserror::Error, Debug)]
2425
#[non_exhaustive]
@@ -74,6 +75,7 @@ pub struct SyncContext {
7475
sync_url: String,
7576
auth_token: Option<HeaderValue>,
7677
max_retries: usize,
78+
push_batch_size: u32,
7779
/// The current durable generation.
7880
durable_generation: u32,
7981
/// Represents the max_frame_no from the server.
@@ -102,6 +104,7 @@ impl SyncContext {
102104
sync_url,
103105
auth_token,
104106
max_retries: DEFAULT_MAX_RETRIES,
107+
push_batch_size: DEFAULT_PUSH_BATCH_SIZE,
105108
client,
106109
durable_generation: 1,
107110
durable_frame_num: 0,
@@ -538,7 +541,7 @@ async fn try_push(
538541

539542
let mut frame_no = start_frame_no;
540543
while frame_no <= end_frame_no {
541-
let batch_size = 128.min(end_frame_no - frame_no + 1);
544+
let batch_size = sync_ctx.push_batch_size.min(end_frame_no - frame_no + 1);
542545
let mut frames = conn.wal_get_frame(frame_no, page_size)?;
543546
if batch_size > 1 {
544547
frames.reserve((batch_size - 1) as usize * frames.len());

0 commit comments

Comments
 (0)