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