risingwave_common/config/
system.rs1use super::*;
18
19macro_rules! define_system_config {
20 ($({ $field:ident, $type:ty, $default:expr, $is_mutable:expr, $doc:literal, $($rest:tt)* },)*) => {
21 paste::paste!(
22 #[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)]
26 pub struct SystemConfig {
27 $(
28 #[doc = $doc]
29 #[serde(default = "default::system::" $field "_opt")]
30 pub $field: Option<$type>,
31 )*
32 }
33 );
34 };
35}
36
37for_all_params!(define_system_config);
38
39impl SystemConfig {
40 #![allow(deprecated)]
41 pub fn into_init_system_params(self) -> SystemParams {
42 macro_rules! fields {
43 ($({ $field:ident, $($rest:tt)* },)*) => {
44 SystemParams {
45 $($field: self.$field.map(Into::into),)*
46 ..Default::default() }
48 };
49 }
50
51 let mut system_params = for_all_params!(fields);
52
53 if let Some(state_store) = &system_params.state_store
55 && let Some(data_directory) = &system_params.data_directory
56 {
57 if system_params.backup_storage_url.is_none() {
58 if let Some(hummock_state_store) = state_store.strip_prefix("hummock+") {
59 system_params.backup_storage_url = Some(hummock_state_store.to_owned());
60 } else {
61 system_params.backup_storage_url = Some("memory".to_owned());
62 }
63 tracing::info!("initialize backup_storage_url based on state_store");
64 }
65 if system_params.backup_storage_directory.is_none() {
66 system_params.backup_storage_directory = Some(format!("{data_directory}/backup"));
67 tracing::info!("initialize backup_storage_directory based on data_directory");
68 }
69 }
70 system_params
71 }
72}
73
74pub mod default {
75 pub use crate::system_param::default as system;
76}