Skip to content

Commit

Permalink
randomize heartbeat send interval
Browse files Browse the repository at this point in the history
  • Loading branch information
arrowtip committed Jul 18, 2024
1 parent 80d1f4d commit 529d74e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/lib/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"

[dependencies]
canzero-config = { path = "../config/" }
rand = "0.8.5"

[dev-dependencies]
canzero-yaml = { path = "../yaml/" }
5 changes: 4 additions & 1 deletion src-tauri/lib/codegen/src/scheduler.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::time::Duration;
use rand::Rng;

use canzero_config::config;

Expand Down Expand Up @@ -38,6 +39,8 @@ pub fn generate_scheduler(
));
}

let heartbeat_interval = 100 + rand::thread_rng().gen_range(0..100);

let num_fragmentation_jobs = node_config
.object_entries()
.iter()
Expand Down Expand Up @@ -302,7 +305,7 @@ static void schedule_get_resp_fragmentation_job(uint32_t *fragmentation_buffer,
}}
static job_t heartbeat_job;
static const uint32_t heartbeat_interval = 100;
static const uint32_t heartbeat_interval = {heartbeat_interval};
static void schedule_heartbeat_job() {{
{indent}heartbeat_job.climax = canzero_get_time();
{indent}heartbeat_job.tag = HEARTBEAT_JOB_TAG;
Expand Down

0 comments on commit 529d74e

Please sign in to comment.