1
1
// TODO(lucio): Move this to `remote/mod.rs`
2
2
3
- use std:: time:: Duration ;
4
- use std:: str:: FromStr ;
5
- use std:: sync:: Arc ;
6
- use std:: sync:: atomic:: AtomicU64 ;
7
3
use libsql_replication:: rpc:: proxy:: {
8
4
describe_result, query_result:: RowResult , Cond , DescribeResult , ExecuteResults , NotCond ,
9
5
OkCond , Positional , Query , ResultRows , State as RemoteState , Step ,
10
6
} ;
11
7
use parking_lot:: Mutex ;
8
+ use std:: str:: FromStr ;
9
+ use std:: sync:: atomic:: AtomicU64 ;
10
+ use std:: sync:: Arc ;
11
+ use std:: time:: Duration ;
12
12
13
13
use crate :: parser;
14
14
use crate :: parser:: StmtKind ;
@@ -168,7 +168,11 @@ impl From<RemoteState> for State {
168
168
}
169
169
170
170
impl 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 {
172
176
let state = Arc :: new ( Mutex :: new ( Inner :: default ( ) ) ) ;
173
177
Self {
174
178
local,
@@ -180,9 +184,16 @@ impl RemoteConnection {
180
184
181
185
fn update_max_write_replication_index ( & self , index : Option < u64 > ) {
182
186
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 ) ;
184
190
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
+ ) {
186
197
Ok ( _) => break ,
187
198
Err ( new_current) => current = new_current,
188
199
}
0 commit comments