File tree Expand file tree Collapse file tree 4 files changed +16
-16
lines changed
Expand file tree Collapse file tree 4 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 11use alloy:: rpc:: types:: Log ;
22use async_trait:: async_trait;
33
4+ pub mod strategy;
5+
46#[ async_trait]
57pub trait EventCallback {
68 /// Called when a matching log is found.
79 async fn on_event ( & self , log : & Log ) -> anyhow:: Result < ( ) > ;
810}
9-
10- pub mod strategy;
Original file line number Diff line number Diff line change @@ -8,15 +8,15 @@ use crate::callback::EventCallback;
88
99use super :: CallbackStrategy ;
1010
11+ pub const BACK_OFF_MAX_RETRIES : u64 = 5 ;
12+ pub const BACK_OFF_MAX_DELAY_MS : u64 = 200 ;
13+
1114#[ derive( Clone , Copy , Debug ) ]
1215pub struct FixedRetryConfig {
1316 pub max_attempts : u64 ,
1417 pub delay_ms : u64 ,
1518}
1619
17- pub const BACK_OFF_MAX_RETRIES : u64 = 5 ;
18- pub const BACK_OFF_MAX_DELAY_MS : u64 = 200 ;
19-
2020impl Default for FixedRetryConfig {
2121 fn default ( ) -> Self {
2222 Self { max_attempts : BACK_OFF_MAX_RETRIES , delay_ms : BACK_OFF_MAX_DELAY_MS }
Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ use async_trait::async_trait;
55
66use crate :: callback:: EventCallback ;
77
8+ pub mod fixed_retry;
9+ pub mod state_sync_aware;
10+
11+ pub use fixed_retry:: { BACK_OFF_MAX_RETRIES , FixedRetryConfig , FixedRetryStrategy } ;
12+ pub use state_sync_aware:: { StateSyncAwareStrategy , StateSyncConfig } ;
13+
814#[ async_trait]
915pub trait CallbackStrategy : Send + Sync {
1016 async fn execute (
@@ -13,9 +19,3 @@ pub trait CallbackStrategy: Send + Sync {
1319 log : & Log ,
1420 ) -> anyhow:: Result < ( ) > ;
1521}
16-
17- pub mod fixed_retry;
18- pub mod state_sync_aware;
19-
20- pub use fixed_retry:: { BACK_OFF_MAX_RETRIES , FixedRetryConfig , FixedRetryStrategy } ;
21- pub use state_sync_aware:: { StateSyncAwareStrategy , StateSyncConfig } ;
Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ use crate::{FixedRetryConfig, callback::EventCallback};
88
99use super :: { CallbackStrategy , fixed_retry:: FixedRetryStrategy } ;
1010
11+ pub const STATE_SYNC_RETRY_INTERVAL : Duration = Duration :: from_secs ( 30 ) ;
12+ pub const STATE_SYNC_RETRY_MAX_INTERVAL : Duration = Duration :: from_secs ( 120 ) ;
13+ pub const STATE_SYNC_RETRY_MAX_ELAPSED : Duration = Duration :: from_secs ( 600 ) ;
14+ pub const STATE_SYNC_RETRY_MULTIPLIER : f64 = 1.5 ;
15+
1116#[ derive( Clone , Copy , Debug ) ]
1217pub struct StateSyncConfig {
1318 pub initial_interval : Duration ,
@@ -16,11 +21,6 @@ pub struct StateSyncConfig {
1621 pub multiplier : f64 ,
1722}
1823
19- pub const STATE_SYNC_RETRY_INTERVAL : Duration = Duration :: from_secs ( 30 ) ;
20- pub const STATE_SYNC_RETRY_MAX_INTERVAL : Duration = Duration :: from_secs ( 120 ) ;
21- pub const STATE_SYNC_RETRY_MAX_ELAPSED : Duration = Duration :: from_secs ( 600 ) ;
22- pub const STATE_SYNC_RETRY_MULTIPLIER : f64 = 1.5 ;
23-
2424impl Default for StateSyncConfig {
2525 fn default ( ) -> Self {
2626 Self {
You can’t perform that action at this time.
0 commit comments