mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-04-23 01:28:04 +00:00
make possible to test, test, and fix feed cutoff
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
use super::commands;
|
||||
use crate::server::{self, Server, Command};
|
||||
|
||||
/// Additional options to pass to the feed command.
|
||||
pub struct CoreOpts {
|
||||
pub feed_timeout: Option<u64>
|
||||
}
|
||||
|
||||
impl Default for CoreOpts {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
feed_timeout: None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Start a telemetry server. We'll use `cargo run` by default, but you can also provide
|
||||
/// env vars to configure the binary that runs for the shard and core process. Either:
|
||||
///
|
||||
@@ -18,7 +31,7 @@ use crate::server::{self, Server, Command};
|
||||
/// - `TELEMETRY_SUBMIT_HOSTS` - hosts (comma separated) to connect to for telemetry `/submit`s.
|
||||
/// - `TELEMETRY_FEED_HOST` - host to connect to for feeds (eg 127.0.0.1:3000)
|
||||
///
|
||||
pub async fn start_server(release_mode: bool) -> Server {
|
||||
pub async fn start_server(release_mode: bool, core_opts: CoreOpts) -> Server {
|
||||
// Start to a single process:
|
||||
if let Ok(bin) = std::env::var("TELEMETRY_BIN") {
|
||||
return Server::start(server::StartOpts::SingleProcess {
|
||||
@@ -38,13 +51,24 @@ pub async fn start_server(release_mode: bool) -> Server {
|
||||
}).await.unwrap();
|
||||
}
|
||||
|
||||
// Start a shard and core process:
|
||||
// Build the shard command
|
||||
let shard_command = std::env::var("TELEMETRY_SHARD_BIN")
|
||||
.map(|val| Command::new(val))
|
||||
.unwrap_or_else(|_| commands::cargo_run_telemetry_shard(release_mode).expect("must be in rust workspace to run shard command"));
|
||||
let core_command = std::env::var("TELEMETRY_CORE_BIN")
|
||||
|
||||
// Build the core command
|
||||
let mut core_command = std::env::var("TELEMETRY_CORE_BIN")
|
||||
.map(|val| Command::new(val))
|
||||
.unwrap_or_else(|_| commands::cargo_run_telemetry_core(release_mode).expect("must be in rust workspace to run core command"));
|
||||
|
||||
// Append additional opts to the core command
|
||||
if let Some(feed_timeout) = core_opts.feed_timeout {
|
||||
core_command = core_command
|
||||
.arg("--feed-timeout")
|
||||
.arg(feed_timeout.to_string());
|
||||
}
|
||||
|
||||
// Star the server
|
||||
Server::start(server::StartOpts::ShardAndCore {
|
||||
shard_command,
|
||||
core_command
|
||||
@@ -53,10 +77,10 @@ pub async fn start_server(release_mode: bool) -> Server {
|
||||
|
||||
/// Start a telemetry core server in debug mode. see [`start_server`] for details.
|
||||
pub async fn start_server_debug() -> Server {
|
||||
start_server(false).await
|
||||
start_server(false, CoreOpts::default()).await
|
||||
}
|
||||
|
||||
/// Start a telemetry core server in release mode. see [`start_server`] for details.
|
||||
pub async fn start_server_release() -> Server {
|
||||
start_server(true).await
|
||||
start_server(true, CoreOpts::default()).await
|
||||
}
|
||||
Reference in New Issue
Block a user