risingwave_common::system_param

Macro impl_default_from_other_params

source
macro_rules! impl_default_from_other_params {
    ($({ $field:ident, $type:ty, $($rest:tt)* },)*) => { ... };
}
Expand description

Define rules to derive a parameter from others. This is useful for parameter type change or semantic change, where a new parameter has to be introduced. When the cluster upgrades to a newer version, we need to ensure the effect of the new parameter is equal to its older versions. For example, if you had interval_sec and now you want finer granularity, you can introduce a new param interval_ms and try to derive it from interval_sec by overriding FromParams trait in OverrideFromParams:

impl FromParams for OverrideFromParams {
    fn interval_ms(params: &PbSystemParams) -> Option<u64> {
        if let Some(sec) = params.interval_sec {
            Some(sec * 1000)
        } else {
            None
        }
    }
}

Note that newer versions must be prioritized during derivation.