Skip to content

Commit

Permalink
refactor: use a dummy Debug impl for SystemParams message
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Aug 6, 2024
1 parent 5933b93 commit 090b23e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ tonic = { package = "madsim-tonic", version = "0.4.1" }
tonic-build = { package = "madsim-tonic-build", version = "0.4.2" }
otlp-embedded = { git = "https://github.com/risingwavelabs/otlp-embedded", rev = "492c244e0be91feb659c0cd48a624bbd96045a33" }
prost = { version = "0.12" }
prost-build = { version = "0.12" }
icelake = { git = "https://github.com/icelake-io/icelake", rev = "07d53893d7788b4e41fc11efad8a6be828405c31", features = [
"prometheus",
] }
Expand Down
2 changes: 1 addition & 1 deletion src/batch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ parking_lot = { workspace = true }
parquet = { workspace = true }
paste = "1"
prometheus = { version = "0.13", features = ["process"] }
prost = "0.12"
prost = { workspace = true }
rand = { workspace = true }
risingwave_common = { workspace = true }
risingwave_common_estimate_size = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion src/connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ paste = "1"
pg_bigdecimal = { git = "https://github.com/risingwavelabs/rust-pg_bigdecimal", rev = "0b7893d88894ca082b4525f94f812da034486f7c" }
postgres-openssl = "0.5.0"
prometheus = { version = "0.13", features = ["process"] }
prost = { version = "0.12", features = ["no-recursion-limit"] }
prost = { workspace = true, features = ["no-recursion-limit"] }
prost-reflect = "0.13"
prost-types = "0.12"
protobuf-native = "0.2.2"
Expand Down
1 change: 1 addition & 0 deletions src/prost/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ workspace-hack = { path = "../workspace-hack" }
[build-dependencies]
fs-err = "2.11"
pbjson-build = "0.5"
prost-build = { workspace = true }
tonic-build = { workspace = true }
walkdir = "2"

Expand Down
15 changes: 11 additions & 4 deletions src/prost/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Put generated files in /src may also benefit IDEs https://github.com/risingwavelabs/risingwave/pull/2581
let out_dir = PathBuf::from(std::env::var("OUT_DIR").expect("OUT_DIR envvar is missing"));
let file_descriptor_set_path: PathBuf = out_dir.join("file_descriptor_set.bin");
tonic_build::configure()

let tonic_config = tonic_build::configure()
.file_descriptor_set_path(file_descriptor_set_path.as_path())
.compile_well_known_types(true)
.protoc_arg("--experimental_allow_proto3_optional")
Expand Down Expand Up @@ -188,10 +189,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.type_attribute(
"hummock.TableWatermarks.EpochNewWatermarks",
"#[derive(Eq)]",
)
// ===================
);

// If any configuration for `prost_build` is not exposed by `tonic_build`, specify it here.
let mut prost_config = prost_build::Config::new();
prost_config.skip_debug(["meta.SystemParams"]);

// Compile the proto files.
tonic_config
.out_dir(out_dir.as_path())
.compile(&protos, &[proto_dir.to_string()])
.compile_with_config(prost_config, &protos, &[proto_dir.to_string()])
.expect("Failed to compile grpc!");

// Implement `serde::Serialize` on those structs.
Expand Down
9 changes: 9 additions & 0 deletions src/prost/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,15 @@ impl catalog::Sink {
}
}

impl std::fmt::Debug for meta::SystemParams {
/// Directly formatting `SystemParams` can be inaccurate or leak sensitive information.
///
/// Use `SystemParamsReader` instead.
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("SystemParams").finish_non_exhaustive()
}
}

#[cfg(test)]
mod tests {
use crate::data::{data_type, DataType};
Expand Down

0 comments on commit 090b23e

Please sign in to comment.