Skip to content

Commit

Permalink
Add reflection support for kuksa.val.v2
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeling committed Nov 5, 2024
1 parent 54755f0 commit 8483c51
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Cargo.lock

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

15 changes: 15 additions & 0 deletions databroker-proto/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

use std::{env, path::PathBuf};

fn main() -> Result<(), Box<dyn std::error::Error>> {
std::env::set_var("PROTOC", protobuf_src::protoc());
tonic_build::configure()
Expand All @@ -28,5 +30,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
],
&["proto"],
)?;

let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
tonic_build::configure()
.file_descriptor_set_path(out_dir.join("kuksa.val.v2_descriptor.bin"))
.compile(
&[
"proto/kuksa/val/v2/val.proto",
"proto/kuksa/val/v2/types.proto",
],
&["proto"],
)
.unwrap();

Ok(())
}
3 changes: 3 additions & 0 deletions databroker-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ pub mod kuksa {
}
pub mod v2 {
tonic::include_proto!("kuksa.val.v2");

pub const FILE_DESCRIPTOR_SET: &[u8] =
tonic::include_file_descriptor_set!("kuksa.val.v2_descriptor");
}
}
}
1 change: 1 addition & 0 deletions databroker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ kuksa-common = { path = "../lib/common"}
kuksa = { path = "../lib/kuksa"}
databroker-proto = { workspace = true }
tonic = { workspace = true, features = ["transport", "channel", "prost"] }
tonic-reflection = "0.11.0"
prost = { workspace = true }
prost-types = { workspace = true }
tokio = { workspace = true, features = [
Expand Down
7 changes: 6 additions & 1 deletion databroker/src/grpc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ where
let mut router = server.add_optional_service(kuksa_val_v1);

if apis.contains(&Api::KuksaValV2) {
router = router.add_optional_service(Some(
let service = tonic_reflection::server::Builder::configure()
.register_encoded_file_descriptor_set(kuksa::val::v2::FILE_DESCRIPTOR_SET)
.build()
.unwrap();

router = router.add_service(service).add_optional_service(Some(
kuksa::val::v2::val_server::ValServer::with_interceptor(
broker.clone(),
authorization.clone(),
Expand Down

0 comments on commit 8483c51

Please sign in to comment.