1
1
cfg_core ! {
2
2
use crate :: EncryptionConfig ;
3
3
}
4
+
4
5
use crate :: { Database , Result } ;
5
6
6
7
use super :: DbType ;
@@ -99,6 +100,7 @@ impl Builder<()> {
99
100
connector: None ,
100
101
version: None ,
101
102
} ,
103
+ connector: None ,
102
104
} ,
103
105
}
104
106
}
@@ -399,6 +401,7 @@ cfg_sync! {
399
401
path: std:: path:: PathBuf ,
400
402
flags: crate :: OpenFlags ,
401
403
remote: Remote ,
404
+ connector: Option <crate :: util:: ConnectorService >,
402
405
}
403
406
404
407
impl Builder <SyncedDatabase > {
@@ -408,6 +411,18 @@ cfg_sync! {
408
411
self
409
412
}
410
413
414
+ /// Provide a custom http connector that will be used to create http connections.
415
+ pub fn connector<C >( mut self , connector: C ) -> Builder <SyncedDatabase >
416
+ where
417
+ C : tower:: Service <http:: Uri > + Send + Clone + Sync + ' static ,
418
+ C :: Response : crate :: util:: Socket ,
419
+ C :: Future : Send + ' static ,
420
+ C :: Error : Into <Box <dyn std:: error:: Error + Send + Sync >>,
421
+ {
422
+ self . inner. connector = Some ( wrap_connector( connector) ) ;
423
+ self
424
+ }
425
+
411
426
/// Build a connection to a local database that can be synced to remote server.
412
427
pub async fn build( self ) -> Result <Database > {
413
428
let SyncedDatabase {
@@ -420,11 +435,16 @@ cfg_sync! {
420
435
connector: _,
421
436
version: _,
422
437
} ,
438
+ connector,
423
439
} = self . inner;
424
440
425
441
let path = path. to_str( ) . ok_or( crate :: Error :: InvalidUTF8Path ) ?. to_owned( ) ;
426
442
427
- let https = super :: connector( ) ?;
443
+ let https = if let Some ( connector) = connector {
444
+ connector
445
+ } else {
446
+ wrap_connector( super :: connector( ) ?)
447
+ } ;
428
448
use tower:: ServiceExt ;
429
449
430
450
let svc = https
0 commit comments