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
Copy file name to clipboardExpand all lines: src/cli.rs
+44-18
Original file line number
Diff line number
Diff line change
@@ -303,6 +303,14 @@ pub struct Options {
303
303
)]
304
304
pubingestor_endpoint:String,
305
305
306
+
#[arg(
307
+
long,
308
+
env = "P_INDEXER_ENDPOINT",
309
+
default_value = "",
310
+
help = "URL to connect to this specific indexer. Default is the address of the server"
311
+
)]
312
+
pubindexer_endpoint:String,
313
+
306
314
#[command(flatten)]
307
315
puboidc:Option<OidcConfig>,
308
316
@@ -404,29 +412,47 @@ impl Options {
404
412
}
405
413
406
414
/// TODO: refactor and document
407
-
pubfnget_url(&self) -> Url{
408
-
ifself.ingestor_endpoint.is_empty(){
409
-
returnformat!(
410
-
"{}://{}",
411
-
self.get_scheme(),
412
-
self.address
413
-
)
414
-
.parse::<Url>()// if the value was improperly set, this will panic before hand
415
-
.unwrap_or_else(|err| {
416
-
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)
417
-
});
418
-
}
419
-
420
-
let ingestor_endpoint = &self.ingestor_endpoint;
415
+
pubfnget_url(&self,mode:Mode) -> Url{
416
+
let(endpoint, env_var) = match mode {
417
+
Mode::Ingest => {
418
+
ifself.ingestor_endpoint.is_empty(){
419
+
returnformat!(
420
+
"{}://{}",
421
+
self.get_scheme(),
422
+
self.address
423
+
)
424
+
.parse::<Url>()// if the value was improperly set, this will panic before hand
425
+
.unwrap_or_else(|err| {
426
+
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)
427
+
});
428
+
}
429
+
(&self.ingestor_endpoint,"P_INGESTOR_ENDPOINT")
430
+
}
431
+
Mode::Index => {
432
+
ifself.indexer_endpoint.is_empty(){
433
+
returnformat!(
434
+
"{}://{}",
435
+
self.get_scheme(),
436
+
self.address
437
+
)
438
+
.parse::<Url>()// if the value was improperly set, this will panic before hand
439
+
.unwrap_or_else(|err| {
440
+
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)
441
+
});
442
+
}
443
+
(&self.indexer_endpoint,"P_INDEXER_ENDPOINT")
444
+
}
445
+
_ => panic!("Invalid mode"),
446
+
};
421
447
422
-
ifingestor_endpoint.starts_with("http"){
423
-
panic!("Invalid value `{}`, please set the environement variable `P_INGESTOR_ENDPOINT` 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.",ingestor_endpoint);
448
+
ifendpoint.starts_with("http"){
449
+
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);
424
450
}
425
451
426
-
let addr_from_env = ingestor_endpoint.split(':').collect::<Vec<&str>>();
452
+
let addr_from_env = endpoint.split(':').collect::<Vec<&str>>();
427
453
428
454
if addr_from_env.len() != 2{
429
-
panic!("Invalid value `{}`, please set the environement variable `P_INGESTOR_ENDPOINT` 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.",ingestor_endpoint);
455
+
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);
0 commit comments