Skip to content

Commit fe7d8d1

Browse files
authored
fix(lazer): use config values in history client (#3093)
1 parent ffcb400 commit fe7d8d1

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazer/sdk/rust/client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-lazer-client"
3-
version = "8.2.0"
3+
version = "8.2.1"
44
edition = "2021"
55
description = "A Rust client for Pyth Lazer"
66
license = "Apache-2.0"

lazer/sdk/rust/client/src/history_client.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ use tokio::{sync::mpsc, time::sleep};
1717
use tracing::{info, warn};
1818
use 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)]
2622
pub struct PythLazerHistoryClientConfig {
@@ -42,10 +38,7 @@ pub struct PythLazerHistoryClientConfig {
4238
}
4339

4440
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()]
4942
}
5043

5144
fn default_update_interval() -> Duration {
@@ -82,11 +75,11 @@ pub struct PythLazerHistoryClient {
8275
impl 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

Comments
 (0)