Skip to content

Commit acd8afb

Browse files
committed
rename ingestor_url to ingestor_endpoint
1 parent 6018975 commit acd8afb

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

server/src/cli.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub struct Cli {
8888
pub mode: Mode,
8989

9090
/// public address for the parseable server ingestor
91-
pub ingestor_url: String,
91+
pub ingestor_endpoint: String,
9292
}
9393

9494
impl Cli {
@@ -115,7 +115,7 @@ impl Cli {
115115
pub const ROW_GROUP_SIZE: &'static str = "row-group-size";
116116
pub const PARQUET_COMPRESSION_ALGO: &'static str = "compression-algo";
117117
pub const MODE: &'static str = "mode";
118-
pub const INGESTOR_URL: &'static str = "ingestor-url";
118+
pub const INGESTOR_ENDPOINT: &'static str = "ingestor-endpoint";
119119
pub const DEFAULT_USERNAME: &'static str = "admin";
120120
pub const DEFAULT_PASSWORD: &'static str = "admin";
121121

@@ -317,9 +317,9 @@ impl Cli {
317317
.help("Mode of operation"),
318318
)
319319
.arg(
320-
Arg::new(Self::INGESTOR_URL)
321-
.long(Self::INGESTOR_URL)
322-
.env("P_INGESTOR_URL")
320+
Arg::new(Self::INGESTOR_ENDPOINT)
321+
.long(Self::INGESTOR_ENDPOINT)
322+
.env("P_INGESTOR_ENDPOINT")
323323
.value_name("URL")
324324
.required(false)
325325
.help("URL to connect to this specific ingestor. Default is the address of the server.")
@@ -367,8 +367,8 @@ impl FromArgMatches for Cli {
367367
.cloned()
368368
.expect("default value for address");
369369

370-
self.ingestor_url = m
371-
.get_one::<String>(Self::INGESTOR_URL)
370+
self.ingestor_endpoint = m
371+
.get_one::<String>(Self::INGESTOR_ENDPOINT)
372372
.cloned()
373373
.unwrap_or_else(String::default);
374374

server/src/utils.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,24 +226,27 @@ impl TimePeriod {
226226
}
227227
}
228228

229-
// TODO: CLEAN UP
230229
pub fn get_address() -> Url {
231-
if CONFIG.parseable.ingestor_url.is_empty() {
232-
let url = format!(
230+
if CONFIG.parseable.ingestor_endpoint.is_empty() {
231+
return format!(
233232
"{}://{}",
234233
CONFIG.parseable.get_scheme(),
235234
CONFIG.parseable.address
236-
);
237-
return url.parse::<Url>().unwrap();
235+
)
236+
.parse::<Url>() // if the value was improperly set, this will panic before hand
237+
.unwrap();
238238
}
239239
let addr_from_env = CONFIG
240240
.parseable
241-
.ingestor_url
241+
.ingestor_endpoint
242242
.split(':')
243243
.collect::<Vec<&str>>();
244244

245245
let mut hostname = addr_from_env[0].to_string();
246246
let mut port = addr_from_env[1].to_string();
247+
248+
// if the env var value fits the pattern $VAR_NAME:$VAR_NAME
249+
// fetch the value from the specified env vars
247250
if hostname.starts_with('$') {
248251
let var_hostname = hostname[1..].to_string();
249252
hostname = get_from_env(&var_hostname);
@@ -259,6 +262,7 @@ pub fn get_address() -> Url {
259262
format!("{}:{}", hostname, port).parse::<Url>().unwrap()
260263
}
261264

265+
/// util fuction to fetch value from an env var
262266
fn get_from_env(var_to_fetch: &str) -> String {
263267
env::var(var_to_fetch).unwrap_or_else(|_| "".to_string())
264268
}

0 commit comments

Comments
 (0)