Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lazer/sdk/rust/client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-lazer-client"
version = "8.2.0"
version = "8.2.1"
edition = "2021"
description = "A Rust client for Pyth Lazer"
license = "Apache-2.0"
Expand Down
17 changes: 5 additions & 12 deletions lazer/sdk/rust/client/src/history_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ use tokio::{sync::mpsc, time::sleep};
use tracing::{info, warn};
use url::Url;

const DEFAULT_URLS: &[&str] = &["https://history.pyth-lazer.dourolabs.app/"];
const DEFAULT_UPDATE_INTERVAL: Duration = Duration::from_secs(30);
const DEFAULT_REQUEST_TIMEOUT: Duration = Duration::from_secs(15);

/// Configuration for the history client.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PythLazerHistoryClientConfig {
Expand All @@ -42,10 +38,7 @@ pub struct PythLazerHistoryClientConfig {
}

fn default_urls() -> Vec<Url> {
DEFAULT_URLS
.iter()
.map(|url| Url::parse(url).unwrap())
.collect()
vec![Url::parse("https://history.pyth-lazer.dourolabs.app/").unwrap()]
}

fn default_update_interval() -> Duration {
Expand Down Expand Up @@ -82,11 +75,11 @@ pub struct PythLazerHistoryClient {
impl PythLazerHistoryClient {
pub fn new(config: PythLazerHistoryClientConfig) -> Self {
Self {
config: Arc::new(config),
client: reqwest::Client::builder()
.timeout(DEFAULT_REQUEST_TIMEOUT)
.timeout(config.request_timeout)
.build()
.expect("failed to initialize reqwest"),
config: Arc::new(config),
}
}

Expand Down Expand Up @@ -192,7 +185,7 @@ impl PythLazerHistoryClient {
) {
info!("starting background task for updating symbols");
loop {
sleep(DEFAULT_UPDATE_INTERVAL).await;
sleep(self.config.update_interval).await;
if handle.upgrade().is_none() {
info!("symbols handle dropped, stopping background task");
return;
Expand Down Expand Up @@ -233,7 +226,7 @@ impl PythLazerHistoryClient {
) {
info!("starting background task for updating symbols");
loop {
sleep(DEFAULT_UPDATE_INTERVAL).await;
sleep(self.config.update_interval).await;
if handle.is_closed() {
info!("symbols channel closed, stopping background task");
return;
Expand Down