Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
fix: move to config
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Paitrault <[email protected]>
  • Loading branch information
Freyskeyd committed Nov 27, 2023
1 parent 9a57258 commit 07bc464
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions crates/topos-tce/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct TceConfiguration {
pub network_bootstrap_timeout: Duration,
pub minimum_cluster_size: usize,
pub version: &'static str,
pub node_sync_interval: u64,
}

#[derive(Debug)]
Expand Down
7 changes: 1 addition & 6 deletions crates/topos-tce/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,7 @@ pub async fn run(
.with_store(validator_store.clone())
.with_gatekeeper_client(gatekeeper_client.clone())
.with_network_client(network_client.clone())
.with_sync_interval_seconds(
std::env::var("TOPOS_SYNC_INTERVAL")
.unwrap_or("1".to_string())
.parse()
.unwrap_or(1),
)
.with_sync_interval_seconds(config.node_sync_interval)
.build()?;

spawn(synchronizer_runtime.into_future());
Expand Down
2 changes: 2 additions & 0 deletions crates/topos/src/components/node/commands/up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ pub struct Up {
/// Usable for cases where edge endpoint is available as infura (or similar cloud provider) endpoint
#[arg(long, env = "TOPOS_NO_EDGE_PROCESS", action)]
pub no_edge_process: bool,

/// Socket of the opentelemetry agent endpoint.
/// If not provided open telemetry will not be used
#[arg(long, env = "TOPOS_OTLP_AGENT")]
pub otlp_agent: Option<String>,

/// Otlp service name.
/// If not provided open telemetry will not be used
#[arg(long, env = "TOPOS_OTLP_SERVICE_NAME")]
Expand Down
1 change: 1 addition & 0 deletions crates/topos/src/components/node/services/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub(crate) fn spawn_tce_process(
.minimum_tce_cluster_size
.unwrap_or(NetworkConfig::MINIMUM_CLUSTER_SIZE),
version: env!("TOPOS_VERSION"),
node_sync_interval: config.node_sync_interval,
};

debug!("TCE args: {tce_config:?}");
Expand Down
10 changes: 10 additions & 0 deletions crates/topos/src/config/tce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use serde::{Deserialize, Serialize};
use crate::config::Config;
use topos_p2p::{Multiaddr, PeerId};

const DEFAULT_NODE_SYNC_INTERVAL: u64 = 1;

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct TceConfig {
Expand Down Expand Up @@ -44,6 +46,14 @@ pub struct TceConfig {
/// Otlp service name
/// If not provided open telemetry will not be used
pub otlp_service_name: Option<String>,

/// Interval in seconds to sync the node with the network
#[serde(default = "default_node_sync_interval")]
pub node_sync_interval: u64,
}

fn default_node_sync_interval() -> u64 {
DEFAULT_NODE_SYNC_INTERVAL
}

fn default_db_path() -> PathBuf {
Expand Down
1 change: 0 additions & 1 deletion tools/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ services:
- env/telemetry.env
environment:
- RUST_LOG=topos=info
- TOPOS_SYNC_INTERVAL=60

spammer:
container_name: spam
Expand Down
1 change: 1 addition & 0 deletions tools/node_config/node/boot/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ graphql-api-addr = "0.0.0.0:4030"
grpc-api-addr = "0.0.0.0:1340"
libp2p-api-addr = "0.0.0.0:9090"
metrics-api-addr = "0.0.0.0:3000"
node-sync-interval = 60
1 change: 1 addition & 0 deletions tools/node_config/node/test/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ graphql-api-addr = "0.0.0.0:4030"
grpc-api-addr = "0.0.0.0:1340"
libp2p-api-addr = "0.0.0.0:9090"
metrics-api-addr = "0.0.0.0:3000"
node-sync-interval = 60

0 comments on commit 07bc464

Please sign in to comment.