-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from Goboolean/feat/envload
dotenv -> env! 방식 변경
- Loading branch information
Showing
5 changed files
with
86 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,40 @@ | ||
//! A connector that fetches data from the HTS service and dumps it into `InfluxDB`. | ||
fn main() { | ||
use std::env; | ||
|
||
let influxdb_url = env::var("INFLUXDB_URL"); | ||
let influxdb_bucket = env::var("INFLUXDB_BUCKET"); | ||
let influxdb_token = env::var("INFLUXDB_TOKEN"); | ||
let influxdb_org = env::var("INFLUXDB_ORG"); | ||
let text_file_path = env::var("TEXT_FILE_PATH"); | ||
|
||
#[cfg(not(debug_assertions))] | ||
{ | ||
use dotenv::dotenv; | ||
use std::env; | ||
|
||
dotenv().expect("Failed to read .env file"); | ||
|
||
let influxdb_url = env::var("INFLUXDB_URL").expect("INFLUX_URL must be set"); | ||
let influxdb_bucket = env::var("INFLUXDB_BUCKET").expect("INFLUX_BUCKET must be set"); | ||
let influxdb_token = env::var("INFLUXDB_TOKEN").expect("INFLUX_TOKEN must be set"); | ||
let influxdb_org = env::var("INFLUXDB_ORG").expect("INFLUX_ORG must be set"); | ||
let text_file_path = env::var("TEXT_FILE_PATH").expect("TEXT_FILE_PATH must be set"); | ||
|
||
println!("cargo:rustc-env=INFLUXDB_URL={}", influxdb_url); | ||
println!("cargo:rustc-env=INFLUXDB_BUCKET={}", influxdb_bucket); | ||
println!("cargo:rustc-env=INFLUXDB_TOKEN={}", influxdb_token); | ||
println!("cargo:rustc-env=INFLUXDB_ORG={}", influxdb_org); | ||
println!("cargo:rustc-env=TEXT_FILE_PATH={}", text_file_path); | ||
if influxdb_url.is_err() { | ||
panic!("INFLUXDB_URL must be set"); | ||
} | ||
|
||
if influxdb_bucket.is_err() { | ||
panic!("INFLUXDB_BUCKET must be set"); | ||
} | ||
|
||
if influxdb_token.is_err() { | ||
panic!("INFLUXDB_TOKEN must be set"); | ||
} | ||
|
||
if influxdb_org.is_err() { | ||
panic!("INFLUXDB_ORG must be set"); | ||
} | ||
|
||
if text_file_path.is_err() { | ||
panic!("TEXT_FILE_PATH must be set"); | ||
} | ||
} | ||
|
||
println!("cargo:rustc-env=INFLUXDB_URL={}", influxdb_url.unwrap_or_default()); | ||
println!("cargo:rustc-env=INFLUXDB_BUCKET={}", influxdb_bucket.unwrap_or_default()); | ||
println!("cargo:rustc-env=INFLUXDB_TOKEN={}", influxdb_token.unwrap_or_default()); | ||
println!("cargo:rustc-env=INFLUXDB_ORG={}", influxdb_org.unwrap_or_default()); | ||
println!("cargo:rustc-env=TEXT_FILE_PATH={}", text_file_path.unwrap_or_default()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters