Skip to content

Commit

Permalink
feat(cat-gateway): add PURGE_SLOT_BUFFER parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
saibatizoku committed Dec 4, 2024
1 parent 89409b7 commit 84afb16
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions catalyst-gateway/bin/src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const CHECK_CONFIG_TICK_DEFAULT: &str = "5s";
const EVENT_DB_URL_DEFAULT: &str =
"postgresql://postgres:postgres@localhost/catalyst_events?sslmode=disable";

/// Default number of slots used as overlap when purging Live Index data.
const PURGE_SLOT_BUFFER_DEFAULT: u64 = 100;

/// Hash the Public IPv4 and IPv6 address of the machine, and convert to a 128 bit V4
/// UUID.
fn calculate_service_uuid() -> String {
Expand Down Expand Up @@ -148,6 +151,9 @@ struct EnvVars {
/// Tick every N seconds until config exists in db
#[allow(unused)]
check_config_tick: Duration,

/// Slot buffer used as overlap when purging Live Index data.
purge_slot_buffer: u64,
}

// Lazy initialization of all env vars which are not command line parameters.
Expand All @@ -173,6 +179,8 @@ static ENV_VARS: LazyLock<EnvVars> = LazyLock::new(|| {
Duration::from_secs(5)
},
};
let purge_slot_buffer =
StringEnvVar::new_as("PURGE_SLOT_BUFFER", PURGE_SLOT_BUFFER_DEFAULT, 0, u64::MAX);

EnvVars {
github_repo_owner: StringEnvVar::new("GITHUB_REPO_OWNER", GITHUB_REPO_OWNER_DEFAULT.into()),
Expand All @@ -199,6 +207,7 @@ static ENV_VARS: LazyLock<EnvVars> = LazyLock::new(|| {
chain_follower: chain_follower::EnvVars::new(),
internal_api_key: StringEnvVar::new_optional("INTERNAL_API_KEY", true),
check_config_tick,
purge_slot_buffer,
}
});

Expand Down Expand Up @@ -374,6 +383,11 @@ impl Settings {
false
}
}

/// Slot buffer used as overlap when purging Live Index data.
pub(crate) fn purge_slot_buffer() -> u64 {
ENV_VARS.purge_slot_buffer
}
}

/// Transform a string list of host names into a vec of host names.
Expand Down

0 comments on commit 84afb16

Please sign in to comment.