File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ mod lazer_exporter {
132
132
use std:: collections:: HashMap ;
133
133
use std:: num:: NonZeroI64 ;
134
134
use std:: sync:: Arc ;
135
+ use std:: time:: Duration ;
135
136
use futures_util:: StreamExt ;
136
137
use pyth_lazer_protocol:: publisher:: PriceFeedDataV1 ;
137
138
use pyth_lazer_protocol:: router:: { Price , PriceFeedId , TimestampUs } ;
@@ -140,6 +141,25 @@ mod lazer_exporter {
140
141
use crate :: agent:: state:: local:: LocalStore ;
141
142
142
143
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 > )
143
163
where
144
164
S : LocalStore ,
145
165
S : Send + Sync + ' static ,
You can’t perform that action at this time.
0 commit comments