mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
central config
This commit is contained in:
1 parent
2a726dc329
commit
e8e1d95006
9 files changed
+53
-7
No files matched your search
Generated
+9
@@ -10705,6 +10705,13 @@ dependencies = [
|
||||
"keccak",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shared_env_var_config"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"easyenv",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
@@ -11290,6 +11297,7 @@ dependencies = [
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"server_environment",
|
||||
"shared_env_var_config",
|
||||
"speculoos",
|
||||
"sqlx",
|
||||
"strum",
|
||||
@@ -13372,6 +13380,7 @@ dependencies = [
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"server_environment",
|
||||
"shared_env_var_config",
|
||||
"sqlx",
|
||||
"tempdir",
|
||||
"tokio",
|
||||
|
||||
@@ -103,6 +103,7 @@ members = [
|
||||
|
||||
# Schema (config): configuration constants for external services
|
||||
"crates/schema/config/rootly_config",
|
||||
"crates/schema/config/shared_env_var_config",
|
||||
|
||||
# Schema (database): queries, database layouts, Redis keys, etc.
|
||||
"crates/schema/database/elasticsearch_schema",
|
||||
@@ -246,6 +247,7 @@ filesys = { path = "crates/lib/files/filesys" }
|
||||
grok_client = { path = "crates/api_clients/grok_client" }
|
||||
rootly_client = { path = "crates/api_clients/rootly_client" }
|
||||
rootly_config = { path = "crates/schema/config/rootly_config" }
|
||||
shared_env_var_config = { path = "crates/schema/config/shared_env_var_config" }
|
||||
http_headers = { path = "crates/lib/http_headers" }
|
||||
images = { path = "crates/lib/files/images" }
|
||||
jobs_common = { path = "crates/lib/jobs_common" }
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "shared_env_var_config"
|
||||
edition = "2024"
|
||||
version = "0.0.1"
|
||||
publish = false
|
||||
|
||||
[lib]
|
||||
name = "shared_env_var_config"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
easyenv.workspace = true
|
||||
@@ -0,0 +1 @@
|
||||
pub mod paging;
|
||||
@@ -0,0 +1,20 @@
|
||||
const ENV_ENABLE_PAGING: &str = "ENABLE_PAGING";
|
||||
const ENV_ROOTLY_API_KEY: &str = "ROOTLY_API_KEY";
|
||||
const ENV_ROOTLY_NOTIFICATION_TARGET_TYPE: &str = "ROOTLY_NOTIFICATION_TARGET_TYPE";
|
||||
const ENV_ROOTLY_NOTIFICATION_TARGET_ID: &str = "ROOTLY_NOTIFICATION_TARGET_ID";
|
||||
|
||||
pub fn env_enable_paging_default_false() -> bool {
|
||||
easyenv::get_env_bool_or_default(ENV_ENABLE_PAGING, false)
|
||||
}
|
||||
|
||||
pub fn env_optional_rootly_api_key() -> Option<String> {
|
||||
easyenv::get_env_string_optional(ENV_ROOTLY_API_KEY)
|
||||
}
|
||||
|
||||
pub fn env_optional_rootly_notification_target_type() -> Option<String> {
|
||||
easyenv::get_env_string_optional(ENV_ROOTLY_NOTIFICATION_TARGET_TYPE)
|
||||
}
|
||||
|
||||
pub fn env_optional_rootly_notification_target_id() -> Option<String> {
|
||||
easyenv::get_env_string_optional(ENV_ROOTLY_NOTIFICATION_TARGET_ID)
|
||||
}
|
||||
@@ -34,6 +34,7 @@ mysql_queries.workspace = true
|
||||
pager = { path = "../../../lib/pager" }
|
||||
rootly_client.workspace = true
|
||||
rootly_config.workspace = true
|
||||
shared_env_var_config.workspace = true
|
||||
server_environment = { path = "../../../lib/server_environment" }
|
||||
|
||||
# External
|
||||
|
||||
@@ -10,7 +10,7 @@ pub fn build_pager(
|
||||
server_environment: server_environment::ServerEnvironment,
|
||||
hostname: &str,
|
||||
) -> (Pager, PagerWorker) {
|
||||
let is_paging_enabled = easyenv::get_env_bool_or_default("ENABLE_PAGING", false);
|
||||
let is_paging_enabled = shared_env_var_config::paging::env_enable_paging_default_false();
|
||||
|
||||
info!("Paging enabled: {}", is_paging_enabled);
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn build_pager(
|
||||
return builder.build_with_worker();
|
||||
}
|
||||
|
||||
let maybe_api_key = easyenv::get_env_string_optional("ROOTLY_API_KEY");
|
||||
let maybe_api_key = shared_env_var_config::paging::env_optional_rootly_api_key();
|
||||
|
||||
match maybe_api_key {
|
||||
Some(api_key) => {
|
||||
@@ -53,8 +53,8 @@ fn build_rootly_pager(builder: PagerBuilder, api_key: String) -> (Pager, PagerWo
|
||||
.urgency_id_medium(ROOTLY_URGENCY_ID_MEDIUM.to_string())
|
||||
.urgency_id_low(ROOTLY_URGENCY_ID_LOW.to_string());
|
||||
|
||||
let target_type = easyenv::get_env_string_optional("ROOTLY_NOTIFICATION_TARGET_TYPE");
|
||||
let target_id = easyenv::get_env_string_optional("ROOTLY_NOTIFICATION_TARGET_ID");
|
||||
let target_type = shared_env_var_config::paging::env_optional_rootly_notification_target_type();
|
||||
let target_id = shared_env_var_config::paging::env_optional_rootly_notification_target_id();
|
||||
|
||||
if let (Some(t_type), Some(t_id)) = (target_type, target_id) {
|
||||
rootly_builder = rootly_builder.notification_target(t_type, t_id);
|
||||
|
||||
@@ -69,6 +69,7 @@ pager.workspace = true
|
||||
password = { path = "../../../lib/password" }
|
||||
rootly_client.workspace = true
|
||||
rootly_config.workspace = true
|
||||
shared_env_var_config.workspace = true
|
||||
primitives = { path = "../../../lib/data/primitives" }
|
||||
prompt_engineering = { path = "../../../lib/deprecated/machine_learning/prompt_engineering" }
|
||||
redis_caching = { path = "../../../lib/caching/redis_caching" }
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn build_pager(
|
||||
return (pager, worker, paging_flags);
|
||||
}
|
||||
|
||||
let maybe_api_key = easyenv::get_env_string_optional("ROOTLY_API_KEY");
|
||||
let maybe_api_key = shared_env_var_config::paging::env_optional_rootly_api_key();
|
||||
|
||||
let (pager, worker) = match maybe_api_key {
|
||||
Some(api_key) => {
|
||||
@@ -58,8 +58,8 @@ fn build_rootly_pager(builder: PagerBuilder, api_key: String) -> (Pager, PagerWo
|
||||
.urgency_id_medium(ROOTLY_URGENCY_ID_MEDIUM.to_string())
|
||||
.urgency_id_low(ROOTLY_URGENCY_ID_LOW.to_string());
|
||||
|
||||
let target_type = easyenv::get_env_string_optional("ROOTLY_NOTIFICATION_TARGET_TYPE");
|
||||
let target_id = easyenv::get_env_string_optional("ROOTLY_NOTIFICATION_TARGET_ID");
|
||||
let target_type = shared_env_var_config::paging::env_optional_rootly_notification_target_type();
|
||||
let target_id = shared_env_var_config::paging::env_optional_rootly_notification_target_id();
|
||||
|
||||
if let (Some(t_type), Some(t_id)) = (target_type, target_id) {
|
||||
rootly_builder = rootly_builder.notification_target(t_type, t_id);
|
||||
|
||||
Reference in new issue
Block a user