@@ -47,6 +47,7 @@ use denokv_proto::SnapshotReadOptions;
4747use denokv_sqlite:: Connection ;
4848use denokv_sqlite:: Sqlite ;
4949use denokv_sqlite:: SqliteBackendError ;
50+ use denokv_sqlite:: SqliteConfig ;
5051use denokv_sqlite:: SqliteNotifier ;
5152use denokv_timemachine:: backup_source_s3:: DatabaseBackupSourceS3 ;
5253use denokv_timemachine:: backup_source_s3:: DatabaseBackupSourceS3Config ;
@@ -212,11 +213,18 @@ async fn run_serve(
212213
213214 let path = Path :: new ( & config. sqlite_path ) ;
214215 let read_only = options. read_only || options. sync_from_s3 ;
215- let ( sqlite, path) = open_sqlite ( path, read_only) ?;
216+ let sqlite_config = SqliteConfig {
217+ batch_timeout : options
218+ . atomic_write_batch_timeout_ms
219+ . map ( std:: time:: Duration :: from_millis) ,
220+ num_workers : options. num_workers ,
221+ } ;
222+ let sqlite = open_sqlite ( path, read_only, sqlite_config. clone ( ) ) ?;
216223 info ! (
217- "Opened{} database at {}" ,
224+ "Opened{} database at {}. Batch timeout: {:?} " ,
218225 if read_only { " read only" } else { "" } ,
219- path,
226+ path. to_string_lossy( ) ,
227+ sqlite_config. batch_timeout,
220228 ) ;
221229
222230 let access_token = options. access_token . as_str ( ) ;
@@ -274,7 +282,7 @@ async fn run_sync(
274282 let proxy_uri = https_proxy. parse ( ) . unwrap ( ) ;
275283 let proxy = Proxy :: new ( Intercept :: All , proxy_uri) ;
276284 let connector = HttpConnector :: new ( ) ;
277- ProxyConnector :: from_proxy ( connector, proxy) . unwrap ( )
285+ ProxyConnector :: from_proxy_unsecured ( connector, proxy)
278286 } ;
279287 let hyper_client =
280288 aws_smithy_client:: hyper_ext:: Adapter :: builder ( ) . build ( proxy) ;
@@ -327,20 +335,27 @@ async fn run_sync(
327335fn open_sqlite (
328336 path : & Path ,
329337 read_only : bool ,
330- ) -> Result < ( Sqlite , String ) , anyhow:: Error > {
338+ config : SqliteConfig ,
339+ ) -> Result < Sqlite , anyhow:: Error > {
331340 let flags = if read_only {
332341 OpenFlags :: SQLITE_OPEN_READ_ONLY | OpenFlags :: SQLITE_OPEN_NO_MUTEX
333342 } else {
334343 OpenFlags :: SQLITE_OPEN_READ_WRITE
335344 | OpenFlags :: SQLITE_OPEN_CREATE
336345 | OpenFlags :: SQLITE_OPEN_NO_MUTEX
337346 } ;
338- let conn = Connection :: open_with_flags ( path, flags) ?;
339347 let notifier = SqliteNotifier :: default ( ) ;
340- let rng: Box < _ > = Box :: new ( rand:: rngs:: StdRng :: from_entropy ( ) ) ;
341- let path = conn. path ( ) . unwrap ( ) . to_owned ( ) ;
342- let sqlite = Sqlite :: new ( conn, notifier, rng) ?;
343- Ok ( ( sqlite, path) )
348+ let sqlite = Sqlite :: new (
349+ || {
350+ Ok ( (
351+ Connection :: open_with_flags ( path, flags) ?,
352+ Box :: new ( rand:: rngs:: StdRng :: from_entropy ( ) ) ,
353+ ) )
354+ } ,
355+ notifier,
356+ config,
357+ ) ?;
358+ Ok ( sqlite)
344359}
345360
346361#[ axum:: debug_handler]
0 commit comments