@@ -17,10 +17,6 @@ use tokio::{sync::mpsc, time::sleep};
17
17
use tracing:: { info, warn} ;
18
18
use url:: Url ;
19
19
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
-
24
20
/// Configuration for the history client.
25
21
#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
26
22
pub struct PythLazerHistoryClientConfig {
@@ -42,10 +38,7 @@ pub struct PythLazerHistoryClientConfig {
42
38
}
43
39
44
40
fn 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( ) ]
49
42
}
50
43
51
44
fn default_update_interval ( ) -> Duration {
@@ -82,11 +75,11 @@ pub struct PythLazerHistoryClient {
82
75
impl PythLazerHistoryClient {
83
76
pub fn new ( config : PythLazerHistoryClientConfig ) -> Self {
84
77
Self {
85
- config : Arc :: new ( config) ,
86
78
client : reqwest:: Client :: builder ( )
87
- . timeout ( DEFAULT_REQUEST_TIMEOUT )
79
+ . timeout ( config . request_timeout )
88
80
. build ( )
89
81
. expect ( "failed to initialize reqwest" ) ,
82
+ config : Arc :: new ( config) ,
90
83
}
91
84
}
92
85
@@ -192,7 +185,7 @@ impl PythLazerHistoryClient {
192
185
) {
193
186
info ! ( "starting background task for updating symbols" ) ;
194
187
loop {
195
- sleep ( DEFAULT_UPDATE_INTERVAL ) . await ;
188
+ sleep ( self . config . update_interval ) . await ;
196
189
if handle. upgrade ( ) . is_none ( ) {
197
190
info ! ( "symbols handle dropped, stopping background task" ) ;
198
191
return ;
@@ -233,7 +226,7 @@ impl PythLazerHistoryClient {
233
226
) {
234
227
info ! ( "starting background task for updating symbols" ) ;
235
228
loop {
236
- sleep ( DEFAULT_UPDATE_INTERVAL ) . await ;
229
+ sleep ( self . config . update_interval ) . await ;
237
230
if handle. is_closed ( ) {
238
231
info ! ( "symbols channel closed, stopping background task" ) ;
239
232
return ;
0 commit comments