Skip to content

Commit 6c5193d

Browse files
committed
libsql: Add max_write_replication_index field to RemoteConnection
Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
1 parent 8fb997e commit 6c5193d

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

libsql/src/database.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,11 @@ impl Database {
575575

576576
let local = LibsqlConnection { conn };
577577
let writer = local.conn.new_connection_writer();
578-
let remote = crate::replication::RemoteConnection::new(local, writer);
578+
let remote = crate::replication::RemoteConnection::new(
579+
local,
580+
writer,
581+
self.max_write_replication_index.clone(),
582+
);
579583
let conn = std::sync::Arc::new(remote);
580584

581585
Ok(Connection { conn })

libsql/src/replication/connection.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use std::str::FromStr;
44
use std::sync::Arc;
5-
5+
use std::sync::atomic::AtomicU64;
66
use libsql_replication::rpc::proxy::{
77
describe_result, query_result::RowResult, Cond, DescribeResult, ExecuteResults, NotCond,
88
OkCond, Positional, Query, ResultRows, State as RemoteState, Step,
@@ -28,6 +28,8 @@ pub struct RemoteConnection {
2828
pub(self) local: LibsqlConnection,
2929
writer: Option<Writer>,
3030
inner: Arc<Mutex<Inner>>,
31+
#[allow(dead_code)]
32+
max_write_replication_index: Arc<AtomicU64>,
3133
}
3234

3335
#[derive(Default, Debug)]
@@ -166,12 +168,13 @@ impl From<RemoteState> for State {
166168
}
167169

168170
impl RemoteConnection {
169-
pub(crate) fn new(local: LibsqlConnection, writer: Option<Writer>) -> Self {
171+
pub(crate) fn new(local: LibsqlConnection, writer: Option<Writer>, max_write_replication_index: Arc<AtomicU64>) -> Self {
170172
let state = Arc::new(Mutex::new(Inner::default()));
171173
Self {
172174
local,
173175
writer,
174176
inner: state,
177+
max_write_replication_index,
175178
}
176179
}
177180

0 commit comments

Comments
 (0)