@@ -17,10 +17,6 @@ use tokio::{sync::mpsc, time::sleep};
1717use tracing:: { info, warn} ;
1818use url:: Url ;
1919
20- const DEFAULT_URLS : & [ & str ] = & [ "https://history.pyth-lazer.dourolabs.app/" ] ;
21- const DEFAULT_UPDATE_INTERVAL : Duration = Duration :: from_secs ( 30 ) ;
22- const DEFAULT_REQUEST_TIMEOUT : Duration = Duration :: from_secs ( 15 ) ;
23-
2420/// Configuration for the history client.
2521#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
2622pub struct PythLazerHistoryClientConfig {
@@ -42,10 +38,7 @@ pub struct PythLazerHistoryClientConfig {
4238}
4339
4440fn default_urls ( ) -> Vec < Url > {
45- DEFAULT_URLS
46- . iter ( )
47- . map ( |url| Url :: parse ( url) . unwrap ( ) )
48- . collect ( )
41+ vec ! [ Url :: parse( "https://history.pyth-lazer.dourolabs.app/" ) . unwrap( ) ]
4942}
5043
5144fn default_update_interval ( ) -> Duration {
@@ -82,11 +75,11 @@ pub struct PythLazerHistoryClient {
8275impl PythLazerHistoryClient {
8376 pub fn new ( config : PythLazerHistoryClientConfig ) -> Self {
8477 Self {
85- config : Arc :: new ( config) ,
8678 client : reqwest:: Client :: builder ( )
87- . timeout ( DEFAULT_REQUEST_TIMEOUT )
79+ . timeout ( config . request_timeout )
8880 . build ( )
8981 . expect ( "failed to initialize reqwest" ) ,
82+ config : Arc :: new ( config) ,
9083 }
9184 }
9285
@@ -192,7 +185,7 @@ impl PythLazerHistoryClient {
192185 ) {
193186 info ! ( "starting background task for updating symbols" ) ;
194187 loop {
195- sleep ( DEFAULT_UPDATE_INTERVAL ) . await ;
188+ sleep ( self . config . update_interval ) . await ;
196189 if handle. upgrade ( ) . is_none ( ) {
197190 info ! ( "symbols handle dropped, stopping background task" ) ;
198191 return ;
@@ -233,7 +226,7 @@ impl PythLazerHistoryClient {
233226 ) {
234227 info ! ( "starting background task for updating symbols" ) ;
235228 loop {
236- sleep ( DEFAULT_UPDATE_INTERVAL ) . await ;
229+ sleep ( self . config . update_interval ) . await ;
237230 if handle. is_closed ( ) {
238231 info ! ( "symbols channel closed, stopping background task" ) ;
239232 return ;
0 commit comments