Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve and build protobuf from remote URLs #63

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
371 changes: 287 additions & 84 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@ members = [
"freyja_apps/e2e",
"freyja_apps/ibeji_integration",
"freyja_apps/in_memory",
"proto/cloud_connector",
"proto/common"
]

[workspace.dependencies]
# Local dependencies
cloud-connector-proto = { path = "proto/cloud_connector" }
proto-common = { path = "proto/common" }

# ESDV dependencies
# Versioning is managed by the Cargo.lock file rather than copying rev properties to all of these

## Freyja
cloud-connector-proto = { git = "https://github.com/eclipse-ibeji/freyja" }
file-service-discovery-adapter = { git = "https://github.com/eclipse-ibeji/freyja" }
freyja = { git = "https://github.com/eclipse-ibeji/freyja" }
freyja-common = { git = "https://github.com/eclipse-ibeji/freyja" }
freyja-build-common = { git = "https://github.com/eclipse-ibeji/freyja" }
freyja-proto-common = { git = "https://github.com/eclipse-ibeji/freyja", package = "proto-common" }
grpc-cloud-adapter = { git = "https://github.com/eclipse-ibeji/freyja" }
grpc-digital-twin-adapter = { git = "https://github.com/eclipse-ibeji/freyja" }
grpc-service-discovery-adapter = { git = "https://github.com/eclipse-ibeji/freyja" }
Expand All @@ -42,9 +47,10 @@ futures = "0.3.30"
log = "0.4.21"
paho-mqtt = "0.12.1"
prost = "0.12.3"
prost-types = "0.12.3"
serde = "1.0.197"
serde_json = "1.0.114"
time = "0.3.34"
time = { version = "0.3.34", features = ["serde-human-readable"] }
tokio = "1.36.0"
tonic = "0.11.0"
tonic-build = "0.11.0"
15 changes: 9 additions & 6 deletions cloud_connectors/mqtt_connector/src/mqtt_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ impl CloudConnector for MQTTConnector {

#[cfg(test)]
mod azure_cloud_connector_tests {
use cloud_connector_proto::v1::UpdateDigitalTwinRequestBuilder;

use super::*;

#[tokio::test]
Expand All @@ -191,11 +189,16 @@ mod azure_cloud_connector_tests {
mqtt_event_grid_topic: String::new(),
};

let builder = UpdateDigitalTwinRequestBuilder::new().string_value(String::new());

let request = tonic::Request::new(builder.build());
let request = UpdateDigitalTwinRequest {
value: Some(Value {
kind: Some(Kind::StringValue(String::new())),
}),
..Default::default()
};

let result = consumer_impl.update_digital_twin(request).await;
let result = consumer_impl
.update_digital_twin(tonic::Request::new(request))
.await;

assert!(result.is_err());
}
Expand Down
19 changes: 19 additions & 0 deletions proto/cloud_connector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# SPDX-License-Identifier: MIT

[package]
name = "cloud-connector-proto"
version = "0.1.0"
edition = "2021"
license = "MIT"

[dependencies]
prost = { workspace = true }
prost-types = { workspace = true }
tonic = { workspace = true }

[build-dependencies]
freyja-build-common = { workspace = true }
freyja-proto-common = { workspace = true }
proto-common = { workspace = true }
12 changes: 12 additions & 0 deletions proto/cloud_connector/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// SPDX-License-Identifier: MIT

use freyja_build_common::compile_remote_proto;
use freyja_proto_common::interface_url;

fn main() -> Result<(), Box<dyn std::error::Error>> {
compile_remote_proto(interface_url!(freyja, CLOUD_CONNECTOR_INTERFACE), &[])?;

Ok(())
}
10 changes: 10 additions & 0 deletions proto/cloud_connector/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// SPDX-License-Identifier: MIT

// Re-export this library so consumers have access to the types used in generation
pub use prost_types;

pub mod v1 {
tonic::include_proto!("cloud_connector");
}
11 changes: 11 additions & 0 deletions proto/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
# SPDX-License-Identifier: MIT

[package]
name = "proto-common"
version = "0.1.0"
edition = "2021"
license = "MIT"

[dependencies]
21 changes: 21 additions & 0 deletions proto/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// SPDX-License-Identifier: MIT

// This module contains constants related to remote protobuf files as well as helpers for referencing them.
// This also helps manage interface versions from a central location, which is particularly helpful for Ibeji since
// the interfaces are referenced in two different crates.

pub const GITHUB_BASE_URL: &str = "https://raw.githubusercontent.com";

pub mod freyja {
pub const REPO_NAME: &str = "eclipse-ibeji/freyja";
pub const VERSION: &str = "0.1.0";
wilyle marked this conversation as resolved.
Show resolved Hide resolved

pub mod interfaces {
pub const CLOUD_CONNECTOR_INTERFACE: &str =
"interfaces/cloud_connector/v1/cloud_connector.proto";
pub const MAPPING_SERVICE_INTERFACE: &str =
"interfaces/mapping_service/v1/mapping_service.proto";
}
}
Loading