Skip to content

Commit 65566fa

Browse files
committed
rnamed lossy to disable_retries
1 parent bdb8186 commit 65566fa

File tree

7 files changed

+36
-31
lines changed

7 files changed

+36
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1111

1212
- The `BlockProposal` StackerDB message serialization struct now includes a `server_version` string, which represents the version of the node that the miner is using. ([#5803](https://github.com/stacks-network/stacks-core/pull/5803))
1313
- Add `vrf_seed` to the `/v3/sortitions` rpc endpoint
14-
- Add `lossy` mode for events_observer disabling automatic retry on error
14+
- Add `disable_retries` mode for events_observer disabling automatic retry on error
1515

1616
### Changed
1717

stackslib/src/config/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ impl Config {
915915
endpoint: observer.endpoint,
916916
events_keys,
917917
timeout_ms: observer.timeout_ms.unwrap_or(1_000),
918-
lossy: observer.lossy.unwrap_or(false),
918+
disable_retries: observer.disable_retries.unwrap_or(false),
919919
});
920920
}
921921
observers
@@ -929,7 +929,7 @@ impl Config {
929929
endpoint: val,
930930
events_keys: vec![EventKeyType::AnyEvent],
931931
timeout_ms: 1_000,
932-
lossy: false,
932+
disable_retries: false,
933933
});
934934
};
935935

@@ -2826,15 +2826,15 @@ pub struct EventObserverConfigFile {
28262826
pub endpoint: String,
28272827
pub events_keys: Vec<String>,
28282828
pub timeout_ms: Option<u64>,
2829-
pub lossy: Option<bool>,
2829+
pub disable_retries: Option<bool>,
28302830
}
28312831

28322832
#[derive(Clone, Default, Debug, Hash, PartialEq, Eq, PartialOrd)]
28332833
pub struct EventObserverConfig {
28342834
pub endpoint: String,
28352835
pub events_keys: Vec<EventKeyType>,
28362836
pub timeout_ms: u64,
2837-
pub lossy: bool,
2837+
pub disable_retries: bool,
28382838
}
28392839

28402840
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd)]

testnet/stacks-node/src/event_dispatcher.rs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ struct EventObserver {
9090
endpoint: String,
9191
/// Timeout for sending events to this observer
9292
timeout: Duration,
93-
/// Lossy observers do not retry on error
94-
lossy: bool,
93+
/// force observers to not retry on error
94+
disable_retries: bool,
9595
}
9696

9797
struct ReceiptPayloadInfo<'a> {
@@ -462,7 +462,7 @@ impl EventObserver {
462462
payload: &serde_json::Value,
463463
full_url: &str,
464464
timeout: Duration,
465-
lossy: bool,
465+
disable_retries: bool,
466466
) {
467467
debug!(
468468
"Event dispatcher: Sending payload"; "url" => %full_url, "payload" => ?payload
@@ -513,8 +513,8 @@ impl EventObserver {
513513
}
514514
}
515515

516-
if lossy {
517-
warn!("Observer is configured in lossy mode: skipping retry of payload");
516+
if disable_retries {
517+
warn!("Observer is configured in disable_retries mode: skipping retry of payload");
518518
return;
519519
}
520520

@@ -534,7 +534,12 @@ impl EventObserver {
534534
}
535535
}
536536

537-
fn new(working_dir: Option<PathBuf>, endpoint: String, timeout: Duration, lossy: bool) -> Self {
537+
fn new(
538+
working_dir: Option<PathBuf>,
539+
endpoint: String,
540+
timeout: Duration,
541+
disable_retries: bool,
542+
) -> Self {
538543
let db_path = if let Some(mut db_path) = working_dir {
539544
db_path.push("event_observers.sqlite");
540545

@@ -553,7 +558,7 @@ impl EventObserver {
553558
db_path,
554559
endpoint,
555560
timeout,
556-
lossy,
561+
disable_retries,
557562
}
558563
}
559564

@@ -568,8 +573,8 @@ impl EventObserver {
568573
};
569574
let full_url = format!("http://{url_str}");
570575

571-
// if the observer is in lossy mode quickly send the payload without checking for the db
572-
if self.lossy {
576+
// if the observer is in "disable_retries" mode quickly send the payload without checking for the db
577+
if self.disable_retries {
573578
Self::send_payload_directly(payload, &full_url, self.timeout, true);
574579
} else if let Some(db_path) = &self.db_path {
575580
let conn =
@@ -1682,7 +1687,7 @@ impl EventDispatcher {
16821687
Some(working_dir),
16831688
conf.endpoint.clone(),
16841689
Duration::from_millis(conf.timeout_ms),
1685-
conf.lossy,
1690+
conf.disable_retries,
16861691
);
16871692

16881693
let observer_index = self.registered_observers.len() as u16;
@@ -2452,7 +2457,7 @@ mod test {
24522457
}
24532458

24542459
#[test]
2455-
fn test_event_dispatcher_lossy() {
2460+
fn test_event_dispatcher_disable_retries() {
24562461
let timeout = Duration::from_secs(5);
24572462
let payload = json!({"key": "value"});
24582463

@@ -2464,30 +2469,30 @@ mod test {
24642469

24652470
let observer = EventObserver::new(None, endpoint, timeout, true);
24662471

2467-
// in non lossy mode this will run forever
2472+
// in non "disable_retries" mode this will run forever
24682473
observer.send_payload(&payload, "/test");
24692474

24702475
// Verify that the payload was sent
24712476
_m.assert();
24722477
}
24732478

24742479
#[test]
2475-
fn test_event_dispatcher_lossy_invalid_url() {
2480+
fn test_event_dispatcher_disable_retries_invalid_url() {
24762481
let timeout = Duration::from_secs(5);
24772482
let payload = json!({"key": "value"});
24782483

24792484
let endpoint = String::from("255.255.255.255");
24802485

24812486
let observer = EventObserver::new(None, endpoint, timeout, true);
24822487

2483-
// in non lossy mode this will run forever
2488+
// in non "disable_retries" mode this will run forever
24842489
observer.send_payload(&payload, "/test");
24852490
}
24862491

24872492
#[test]
24882493
#[ignore]
2489-
/// This test generates a new block and ensures the lossy events_observer will not block.
2490-
fn block_event_with_lossy_observer() {
2494+
/// This test generates a new block and ensures the "disable_retries" events_observer will not block.
2495+
fn block_event_with_disable_retries_observer() {
24912496
let dir = tempdir().unwrap();
24922497
let working_dir = dir.path().to_path_buf();
24932498

@@ -2496,7 +2501,7 @@ mod test {
24962501
endpoint: String::from("255.255.255.255"),
24972502
events_keys: vec![EventKeyType::MinedBlocks],
24982503
timeout_ms: 1000,
2499-
lossy: true,
2504+
disable_retries: true,
25002505
};
25012506
event_dispatcher.register_observer(&config, working_dir);
25022507

@@ -2505,7 +2510,7 @@ mod test {
25052510
txs: vec![],
25062511
};
25072512

2508-
// this will block forever in non lossy mode
2513+
// this will block forever in non "disable_retries" mode
25092514
event_dispatcher.process_mined_nakamoto_block_event(
25102515
0,
25112516
&nakamoto_block,

testnet/stacks-node/src/tests/epoch_22.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ fn pox_2_unlock_all() {
644644
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
645645
events_keys: vec![EventKeyType::AnyEvent],
646646
timeout_ms: 1000,
647-
lossy: false,
647+
disable_retries: false,
648648
});
649649
conf.initial_balances.append(&mut initial_balances);
650650

testnet/stacks-node/src/tests/neon_integrations.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ pub mod test_observer {
657657
endpoint: format!("localhost:{EVENT_OBSERVER_PORT}"),
658658
events_keys: event_keys.to_vec(),
659659
timeout_ms: 1000,
660-
lossy: false,
660+
disable_retries: false,
661661
});
662662
}
663663

@@ -7491,7 +7491,7 @@ fn atlas_integration_test() {
74917491
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
74927492
events_keys: vec![EventKeyType::AnyEvent],
74937493
timeout_ms: 1000,
7494-
lossy: false,
7494+
disable_retries: false,
74957495
});
74967496

74977497
conf_follower_node.node.always_use_affirmation_maps = false;
@@ -8025,7 +8025,7 @@ fn antientropy_integration_test() {
80258025
endpoint: format!("localhost:{}", test_observer::EVENT_OBSERVER_PORT),
80268026
events_keys: vec![EventKeyType::AnyEvent],
80278027
timeout_ms: 1000,
8028-
lossy: false,
8028+
disable_retries: false,
80298029
});
80308030

80318031
conf_follower_node.node.mine_microblocks = true;

testnet/stacks-node/src/tests/signer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ fn setup_stx_btc_node<G: FnMut(&mut NeonConfig)>(
736736
EventKeyType::BurnchainBlocks,
737737
],
738738
timeout_ms: 1000,
739-
lossy: false,
739+
disable_retries: false,
740740
});
741741
}
742742

@@ -752,7 +752,7 @@ fn setup_stx_btc_node<G: FnMut(&mut NeonConfig)>(
752752
EventKeyType::BurnchainBlocks,
753753
],
754754
timeout_ms: 1000,
755-
lossy: false,
755+
disable_retries: false,
756756
});
757757

758758
// The signers need some initial balances in order to pay for epoch 2.5 transaction votes

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4431,7 +4431,7 @@ fn signer_set_rollover() {
44314431
EventKeyType::BurnchainBlocks,
44324432
],
44334433
timeout_ms: 1000,
4434-
lossy: false,
4434+
disable_retries: false,
44354435
});
44364436
}
44374437
naka_conf.node.rpc_bind = rpc_bind.clone();
@@ -8877,7 +8877,7 @@ fn injected_signatures_are_ignored_across_boundaries() {
88778877
EventKeyType::BurnchainBlocks,
88788878
],
88798879
timeout_ms: 1000,
8880-
lossy: false,
8880+
disable_retries: false,
88818881
});
88828882
naka_conf.node.rpc_bind = rpc_bind.clone();
88838883
},

0 commit comments

Comments
 (0)