diff --git a/Cargo.lock b/Cargo.lock index f7b3e59..7359209 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,6 +175,35 @@ dependencies = [ "tower-service", ] +[[package]] +name = "azure-cloud-connector-adapter" +version = "0.1.0" +dependencies = [ + "async-trait", + "azure-cloud-connector-proto", + "freyja-build-common", + "freyja-common", + "futures", + "log", + "serde", + "serde_json", + "tempfile", + "tokio", + "tokio-stream", + "tonic", + "tower", +] + +[[package]] +name = "azure-cloud-connector-proto" +version = "0.1.0" +dependencies = [ + "prost", + "tokio", + "tonic", + "tonic-build 0.11.0", +] + [[package]] name = "backtrace" version = "0.3.69" diff --git a/Cargo.toml b/Cargo.toml index 402a400..a6a1a9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ resolver = "2" members = [ "cloud_connectors/azure/mqtt_connector", + "cloud_connectors/azure/proto-build", "freyja_adapters/cloud/azure_cloud_connector_adapter", "freyja_apps/e2e", "freyja_apps/ibeji_integration", diff --git a/cloud_connectors/azure/mqtt_connector/README.md b/cloud_connectors/azure/mqtt_connector/README.md index 03a092c..d8d9aa7 100644 --- a/cloud_connectors/azure/mqtt_connector/README.md +++ b/cloud_connectors/azure/mqtt_connector/README.md @@ -210,4 +210,4 @@ To build and run the MQTT connector, run the following command: cargo run -p mqtt-cloud-connector ``` -This will rebuild the project as necessary before running it. If you just want to build the project without running it, use `cargo build` instead of `cargo run`. \ No newline at end of file +This will rebuild the project as necessary before running it. If you only want to build the project without running it, use `cargo build` instead of `cargo run`. diff --git a/cloud_connectors/azure/proto-build/Cargo.toml b/cloud_connectors/azure/proto-build/Cargo.toml new file mode 100644 index 0000000..871a954 --- /dev/null +++ b/cloud_connectors/azure/proto-build/Cargo.toml @@ -0,0 +1,17 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. +# SPDX-License-Identifier: MIT + +[package] +name = "azure-cloud-connector-proto" +version = "0.1.0" +edition = "2021" +license = "MIT" + +[dependencies] +tonic = { workspace = true } +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +prost = { workspace = true } + +[build-dependencies] +tonic-build = { workspace = true } \ No newline at end of file diff --git a/cloud_connectors/azure/proto-build/build.rs b/cloud_connectors/azure/proto-build/build.rs new file mode 100644 index 0000000..e3cea87 --- /dev/null +++ b/cloud_connectors/azure/proto-build/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// SPDX-License-Identifier: MIT + +fn main() { + tonic_build::compile_protos("../proto/azure_cloud_connector.proto").unwrap(); +} diff --git a/cloud_connectors/azure/proto-build/src/lib.rs b/cloud_connectors/azure/proto-build/src/lib.rs new file mode 100644 index 0000000..52cf01a --- /dev/null +++ b/cloud_connectors/azure/proto-build/src/lib.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// SPDX-License-Identifier: MIT + +pub mod azure_cloud_connector { + tonic::include_proto!("azure_cloud_connector"); +} diff --git a/cloud_connectors/azure/sample-dtdl/README.md b/cloud_connectors/azure/sample-dtdl/README.md index 1be45f7..2a8da90 100644 --- a/cloud_connectors/azure/sample-dtdl/README.md +++ b/cloud_connectors/azure/sample-dtdl/README.md @@ -46,7 +46,7 @@ The steps below will guide you on manually deploying the Azure Digital Twins res 1. Set up your [Azure Digital Twin Instance](https://learn.microsoft.com/en-us/azure/digital-twins/quickstart-azure-digital-twins-explorer#set-up-azure-digital-twins). - If you wish to use the default mappings in the [.freyja directory](../../../.frejya/), create the following instances: + If you wish to use the default mappings in this repository, create the following instances: * vehicle * hvac diff --git a/freyja_adapters/cloud/azure_cloud_connector_adapter/src/azure_cloud_connector_adapter.rs b/freyja_adapters/cloud/azure_cloud_connector_adapter/src/azure_cloud_connector_adapter.rs index f2edbc0..607bc37 100644 --- a/freyja_adapters/cloud/azure_cloud_connector_adapter/src/azure_cloud_connector_adapter.rs +++ b/freyja_adapters/cloud/azure_cloud_connector_adapter/src/azure_cloud_connector_adapter.rs @@ -54,21 +54,21 @@ impl AzureCloudConnectorAdapter { ) -> Result { Ok(CloudDigitalTwinInstance { model_id: cloud_message - .cloud_signal + .metadata .get(MODEL_ID_KEY) .ok_or_else(|| { CloudAdapterError::key_not_found(format!("Cannot find key: {MODEL_ID_KEY:}")) })? .clone(), instance_id: cloud_message - .cloud_signal + .metadata .get(INSTANCE_ID_KEY) .ok_or_else(|| { CloudAdapterError::key_not_found(format!("Cannot find key: {INSTANCE_ID_KEY:}")) })? .clone(), instance_property_path: cloud_message - .cloud_signal + .metadata .get(INSTANCE_PROPERTY_PATH_KEY) .ok_or_else(|| { CloudAdapterError::key_not_found(format!( @@ -153,7 +153,7 @@ mod azure_cloud_connector_tests { #[tokio::test] async fn get_instance_info_from_message_test() { let cloud_message = CloudMessageRequest { - cloud_signal: HashMap::new(), + metadata: HashMap::new(), signal_value: String::new(), signal_timestamp: String::new(), };