You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds the basic framework required to support
multiple query nodes on the Enterprise version.
This PR doesn't change any behavior for OSS
mode.
---------
Signed-off-by: Nikhil Sinha <[email protected]>
Copy file name to clipboardExpand all lines: src/cli.rs
+75-62
Original file line number
Diff line number
Diff line change
@@ -328,6 +328,14 @@ pub struct Options {
328
328
)]
329
329
pubindexer_endpoint:String,
330
330
331
+
#[arg(
332
+
long,
333
+
env = "P_QUERIER_ENDPOINT",
334
+
default_value = "",
335
+
help = "URL to connect to this specific querier. Default is the address of the server"
336
+
)]
337
+
pubquerier_endpoint:String,
338
+
331
339
#[command(flatten)]
332
340
puboidc:Option<OidcConfig>,
333
341
@@ -439,83 +447,88 @@ impl Options {
439
447
}
440
448
}
441
449
442
-
/// TODO: refactor and document
450
+
/// get the address of the server
451
+
/// based on the mode
443
452
pubfnget_url(&self,mode:Mode) -> Url{
444
-
let(endpoint, env_var) = match mode {
445
-
Mode::Ingest => {
446
-
ifself.ingestor_endpoint.is_empty(){
447
-
returnformat!(
448
-
"{}://{}",
449
-
self.get_scheme(),
450
-
self.address
451
-
)
452
-
.parse::<Url>()// if the value was improperly set, this will panic before hand
453
-
.unwrap_or_else(|err| {
454
-
panic!("{err}, failed to parse `{}` as Url. Please set the environment variable `P_ADDR` to `<ip address>:<port>` without the scheme (e.g., 192.168.1.1:8000). Please refer to the documentation: https://logg.ing/env for more details.",self.address)
455
-
});
456
-
}
457
-
(&self.ingestor_endpoint,"P_INGESTOR_ENDPOINT")
458
-
}
459
-
Mode::Index => {
460
-
ifself.indexer_endpoint.is_empty(){
461
-
returnformat!(
462
-
"{}://{}",
463
-
self.get_scheme(),
464
-
self.address
465
-
)
466
-
.parse::<Url>()// if the value was improperly set, this will panic before hand
467
-
.unwrap_or_else(|err| {
468
-
panic!("{err}, failed to parse `{}` as Url. Please set the environment variable `P_ADDR` to `<ip address>:<port>` without the scheme (e.g., 192.168.1.1:8000). Please refer to the documentation: https://logg.ing/env for more details.",self.address)
panic!("Invalid value `{}`, please set the environement variable `{env_var}` to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details.", endpoint);
478
-
}
479
-
480
-
let addr_from_env = endpoint.split(':').collect::<Vec<&str>>();
460
+
self.parse_endpoint(&endpoint)
461
+
}
481
462
482
-
if addr_from_env.len() != 2{
483
-
panic!("Invalid value `{}`, please set the environement variable `{env_var}` to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details.", endpoint);
463
+
/// get the endpoint for the server
464
+
/// if env var is empty, use the address, else use the env var
"Invalid value `{}`, please set the environment variable `{}` to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details.",
472
+
endpoint, env_var
473
+
);
474
+
}
475
+
endpoint.to_string()
484
476
}
477
+
}
485
478
486
-
letmut hostname = addr_from_env[0].to_string();
487
-
letmut port = addr_from_env[1].to_string();
479
+
/// parse the endpoint to get the address and port
480
+
/// if the address is an env var, resolve it
481
+
/// if the port is an env var, resolve it
482
+
fnparse_endpoint(&self,endpoint:&str) -> Url{
483
+
let addr_parts:Vec<&str> = endpoint.split(':').collect();
484
+
485
+
if addr_parts.len() != 2{
486
+
panic!(
487
+
"Invalid value `{}`, please set the environment variable to `<ip address / DNS>:<port>` without the scheme (e.g., 192.168.1.1:8000 or example.com:8000). Please refer to the documentation: https://logg.ing/env for more details.",
488
+
endpoint
489
+
);
490
+
}
488
491
489
-
// if the env var value fits the pattern $VAR_NAME:$VAR_NAME
let hostname = self.resolve_env_var(addr_parts[0]);
493
+
let port = self.resolve_env_var(addr_parts[1]);
494
494
495
-
if hostname.is_empty(){
496
-
panic!("The environement variable `{}` is not set, please set as <ip address / DNS> without the scheme (e.g., 192.168.1.1 or example.com). Please refer to the documentation: https://logg.ing/env for more details.", var_hostname);
497
-
}
498
-
if hostname.starts_with("http"){
499
-
panic!("Invalid value `{}`, please set the environement variable `{}` to `<ip address / DNS>` without the scheme (e.g., 192.168.1.1 or example.com). Please refer to the documentation: https://logg.ing/env for more details.", hostname, var_hostname);
let resolved_value = env::var(env_var).unwrap_or_else(|_| {
504
+
panic!(
505
+
"The environment variable `{}` is not set. Please set it to a valid value. Refer to the documentation: https://logg.ing/env for more details.",
506
+
env_var
507
+
);
508
+
});
508
509
509
-
ifport.is_empty(){
510
+
ifresolved_value.starts_with("http"){
510
511
panic!(
511
-
"Port is not set in the environement variable `{}`. Please refer to the documentation: https://logg.ing/env for more details.",
512
-
var_port
512
+
"Invalid value `{}`, please set the environment variable `{}` to `<ip address / DNS>` without the scheme (e.g., 192.168.1.1 or example.com). Please refer to the documentation: https://logg.ing/env for more details.",
"{err}, failed to parse `{}` as Url. Please set the environment variable `P_ADDR` to `<ip address>:<port>` without the scheme (e.g., 192.168.1.1:8000). Please refer to the documentation: https://logg.ing/env for more details.",
0 commit comments