mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-29 04:05:21 +08:00
Get rid of the retry count
This commit is contained in:
@@ -30,5 +30,4 @@ amount = 10000000000000000
|
||||
|
||||
# [[events_observer]]
|
||||
# endpoint = "http://127.0.0.1:8080"
|
||||
# retry_count = 5
|
||||
# events_keys = ["*"]
|
||||
|
||||
@@ -31,5 +31,4 @@ amount = 10000000000000000
|
||||
|
||||
# [[events_observer]]
|
||||
# endpoint = "http://127.0.0.1:8080"
|
||||
# retry_count = 5
|
||||
# events_keys = ["*"]
|
||||
|
||||
@@ -31,5 +31,4 @@ amount = 10000000000000000
|
||||
|
||||
# [[events_observer]]
|
||||
# endpoint = "http://127.0.0.1:8080"
|
||||
# retry_count = 5
|
||||
# events_keys = ["*"]
|
||||
|
||||
@@ -280,8 +280,6 @@ impl Config {
|
||||
None => vec![]
|
||||
};
|
||||
|
||||
let default_retry_count = 5;
|
||||
|
||||
let mut events_observers = match config_file.events_observer {
|
||||
Some(raw_observers) => {
|
||||
let mut observers = vec![];
|
||||
@@ -292,7 +290,6 @@ impl Config {
|
||||
|
||||
observers.push(EventObserverConfig {
|
||||
endpoint: observer.endpoint,
|
||||
retry_count: observer.retry_count.unwrap_or(default_retry_count),
|
||||
events_keys
|
||||
});
|
||||
}
|
||||
@@ -306,7 +303,6 @@ impl Config {
|
||||
Ok(val) => {
|
||||
events_observers.push(EventObserverConfig {
|
||||
endpoint: val,
|
||||
retry_count: default_retry_count,
|
||||
events_keys: vec![EventKeyType::AnyEvent],
|
||||
})
|
||||
},
|
||||
@@ -638,14 +634,12 @@ pub struct NodeConfigFile {
|
||||
#[derive(Clone, Deserialize, Default)]
|
||||
pub struct EventObserverConfigFile {
|
||||
pub endpoint: String,
|
||||
pub retry_count: Option<u8>,
|
||||
pub events_keys: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct EventObserverConfig {
|
||||
pub endpoint: String,
|
||||
pub retry_count: u8,
|
||||
pub events_keys: Vec<EventKeyType>,
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ use super::node::{ChainTip};
|
||||
#[derive(Debug)]
|
||||
struct EventObserver {
|
||||
endpoint: String,
|
||||
retry_count: u8
|
||||
}
|
||||
|
||||
impl EventObserver {
|
||||
@@ -85,7 +84,6 @@ impl EventObserver {
|
||||
});
|
||||
|
||||
// Send payload
|
||||
let mut retry_count = 0;
|
||||
let mut backoff: f64 = 1.0;
|
||||
let mut rng = thread_rng();
|
||||
loop {
|
||||
@@ -106,12 +104,6 @@ impl EventObserver {
|
||||
}
|
||||
};
|
||||
|
||||
if retry_count >= self.retry_count {
|
||||
error!("Event dispatcher: exponential backoff failed");
|
||||
panic!();
|
||||
}
|
||||
|
||||
retry_count += 1;
|
||||
backoff = (2.0 * backoff + (backoff * rng.gen_range(0.0, 1.0))).min(60.0);
|
||||
let duration = Duration::from_millis((backoff * 1_000.0) as u64);
|
||||
info!("Event dispatcher will retry posting in {:?}", duration);
|
||||
@@ -207,7 +199,6 @@ impl EventDispatcher {
|
||||
info!("Registering event observer at: {}", conf.endpoint);
|
||||
let event_observer = EventObserver {
|
||||
endpoint: conf.endpoint.clone(),
|
||||
retry_count: conf.retry_count
|
||||
};
|
||||
|
||||
let observer_index = self.registered_observers.len() as u16;
|
||||
|
||||
Reference in New Issue
Block a user