Skip to content

Commit 944551e

Browse files
committed
Retry on Lazer exporter failure in relayer connection
1 parent 9742119 commit 944551e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/agent/services/lazer_exporter.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ mod lazer_exporter {
132132
use std::collections::HashMap;
133133
use std::num::NonZeroI64;
134134
use std::sync::Arc;
135+
use std::time::Duration;
135136
use futures_util::StreamExt;
136137
use pyth_lazer_protocol::publisher::PriceFeedDataV1;
137138
use pyth_lazer_protocol::router::{Price, PriceFeedId, TimestampUs};
@@ -140,6 +141,25 @@ mod lazer_exporter {
140141
use crate::agent::state::local::LocalStore;
141142

142143
pub async fn lazer_exporter<S>(config: Config, state: Arc<S>)
144+
where
145+
S: LocalStore,
146+
S: Send + Sync + 'static,
147+
{
148+
let mut failure_count = 0;
149+
let retry_duration = Duration::from_secs(1);
150+
151+
loop {
152+
run(&config, state.clone()).await;
153+
154+
failure_count += 1;
155+
tracing::error!("Lazer exporter failed {} times; retrying in {:?}", failure_count, retry_duration);
156+
tokio::time::sleep(retry_duration).await;
157+
158+
// TODO: Back off or crash altogether on persistent failure
159+
}
160+
}
161+
162+
async fn run<S>(config: &Config, state: Arc<S>)
143163
where
144164
S: LocalStore,
145165
S: Send + Sync + 'static,

0 commit comments

Comments
 (0)