Skip to content

Commit

Permalink
Digital Twin Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbeitz committed Apr 25, 2024
1 parent 788f4d0 commit 1950d82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ jobs:
- name: Cache Dependencies
uses: Swatinem/rust-cache@v2
- name: Build
# Build the project with the `managed_subscribe` and `digital_twin_graph` features enabled.
# Build the project with the `managed_subscribe`, `digital_twin_graph` and `digital_twin_registry` features enabled.
run: cargo build --features "managed_subscribe,digital_twin_graph,digital_twin_registry"
- name: Test
# Test the project with the `managed_subscribe` and `digital_twin_graph` features enabled.
# Test the project with the `managed_subscribe`, `digital_twin_graph` and `digital_twin_registry` features enabled.
run: cargo test --features "managed_subscribe,digital_twin_graph,digital_twin_registry"
22 changes: 11 additions & 11 deletions core/invehicle-digital-twin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,47 +113,47 @@ where
let mut server: GrpcServer<Identity> = GrpcServer::new(addr);

#[cfg(feature = "managed_subscribe")]
// (1) Adds the Managed Subscribe module to the service.
// Adds the Managed Subscribe module to the service.
let mut server = {
// (2) Initialize the Managed Subscribe module, which implements GrpcModule.
// Initialize the Managed Subscribe module, which implements GrpcModule.
let managed_subscribe_module = ManagedSubscribeModule::new().await.map_err(|error| {
error!("Unable to create Managed Subscribe module.");
error
})?;

// (3) Create interceptor layer to be added to the server.
// Create interceptor layer to be added to the server.
let managed_subscribe_layer =
GrpcInterceptorLayer::new(Box::new(managed_subscribe_module.create_interceptor()));

// (4) Add the interceptor(s) to the middleware stack.
// Add the interceptor(s) to the middleware stack.
let current_middleware = server.middleware.clone();
let new_middleware = current_middleware.layer(managed_subscribe_layer);

info!("Initialized Managed Subscribe module.");

// (5) Add the module with the updated middleware stack to the server.
// Add the module with the updated middleware stack to the server.
server.add_module(new_middleware, Box::new(managed_subscribe_module))
};

#[cfg(feature = "digital_twin_graph")]
// (1) Adds the Managed Subscribe module to the service.
// Adds the Digital Twin Graph module to the service.
let mut server = {
// (2) Initialize the Digital Twin Graph module, which implements GrpcModule.
// Initialize the Digital Twin Graph module, which implements GrpcModule.
let digital_twin_graph_module = DigitalTwinGraphModule::new().await.map_err(|error| {
error!("Unable to create Digital Twin Graph module.");
error
})?;

info!("Initialized Digital Twin Graph module.");

// (3) Add the module with the updated middleware stack to the server.
// Add the module with the updated middleware stack to the server.
server.add_module(server.middleware.clone(), Box::new(digital_twin_graph_module))
};

#[cfg(feature = "digital_twin_registry")]
// (1) Adds the Managed Subscribe module to the service.
// Adds the Digital Twin Registry module to the service.
let mut server = {
// (2) Initialize the Digital Twin Registry module, which implements GrpcModule.
// Initialize the Digital Twin Registry module, which implements GrpcModule.
let digital_twin_registry_module =
DigitalTwinRegistryModule::new().await.map_err(|error| {
error!("Unable to create Digital Twin Registry module.");
Expand All @@ -162,7 +162,7 @@ where

info!("Initialized Digital Twin Registry module.");

// (3) Add the module with the updated middleware stack to the server.
// Add the module with the updated middleware stack to the server.
server.add_module(server.middleware.clone(), Box::new(digital_twin_registry_module))
};

Expand Down

0 comments on commit 1950d82

Please sign in to comment.