11// TODO(lucio): Move this to `remote/mod.rs`
22
3- use std:: time:: Duration ;
4- use std:: str:: FromStr ;
5- use std:: sync:: Arc ;
6- use std:: sync:: atomic:: AtomicU64 ;
73use libsql_replication:: rpc:: proxy:: {
84 describe_result, query_result:: RowResult , Cond , DescribeResult , ExecuteResults , NotCond ,
95 OkCond , Positional , Query , ResultRows , State as RemoteState , Step ,
106} ;
117use parking_lot:: Mutex ;
8+ use std:: str:: FromStr ;
9+ use std:: sync:: atomic:: AtomicU64 ;
10+ use std:: sync:: Arc ;
11+ use std:: time:: Duration ;
1212
1313use crate :: parser;
1414use crate :: parser:: StmtKind ;
@@ -168,7 +168,11 @@ impl From<RemoteState> for State {
168168}
169169
170170impl RemoteConnection {
171- pub ( crate ) fn new ( local : LibsqlConnection , writer : Option < Writer > , max_write_replication_index : Arc < AtomicU64 > ) -> Self {
171+ pub ( crate ) fn new (
172+ local : LibsqlConnection ,
173+ writer : Option < Writer > ,
174+ max_write_replication_index : Arc < AtomicU64 > ,
175+ ) -> Self {
172176 let state = Arc :: new ( Mutex :: new ( Inner :: default ( ) ) ) ;
173177 Self {
174178 local,
@@ -180,9 +184,16 @@ impl RemoteConnection {
180184
181185 fn update_max_write_replication_index ( & self , index : Option < u64 > ) {
182186 if let Some ( index) = index {
183- let mut current = self . max_write_replication_index . load ( std:: sync:: atomic:: Ordering :: SeqCst ) ;
187+ let mut current = self
188+ . max_write_replication_index
189+ . load ( std:: sync:: atomic:: Ordering :: SeqCst ) ;
184190 while index > current {
185- match self . max_write_replication_index . compare_exchange ( current, index, std:: sync:: atomic:: Ordering :: SeqCst , std:: sync:: atomic:: Ordering :: SeqCst ) {
191+ match self . max_write_replication_index . compare_exchange (
192+ current,
193+ index,
194+ std:: sync:: atomic:: Ordering :: SeqCst ,
195+ std:: sync:: atomic:: Ordering :: SeqCst ,
196+ ) {
186197 Ok ( _) => break ,
187198 Err ( new_current) => current = new_current,
188199 }
0 commit comments