Skip to content

Commit d4e093b

Browse files
authored
Chariott usage cleanup (eclipse-ibeji#31)
1 parent e6ae4e0 commit d4e093b

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

core/invehicle-digital-twin/src/main.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use core_protobuf_data_access::chariott::runtime::v1::{
1010
};
1111
use core_protobuf_data_access::digital_twin::v1::digital_twin_server::DigitalTwinServer;
1212
use env_logger::{Builder, Target};
13-
use log::{debug, info, LevelFilter};
13+
use log::{debug, error, info, LevelFilter};
1414
use parking_lot::RwLock;
1515
use std::collections::HashMap;
1616
use std::net::SocketAddr;
@@ -54,13 +54,11 @@ pub async fn register_digital_twin_service_with_chariott(
5454

5555
let request = Request::new(RegisterRequest { service, intents });
5656

57-
let response = client
57+
let _response = client
5858
.register(request)
5959
.await
6060
.map_err(|_| Status::internal("Chariott register request failed"))?;
6161

62-
info!("{:?}", response.into_inner());
63-
6462
Ok(())
6563
}
6664

@@ -96,11 +94,21 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
9694
// after 15 seconds unless the CHARIOTT_REGISTRY_TTL_SECS environment variable is set. Please make sure that
9795
// it is set (and exported) in the shell running Chariott before Chariott has started.
9896
if chariott_url_option.is_some() {
99-
register_digital_twin_service_with_chariott(
97+
match register_digital_twin_service_with_chariott(
10098
&chariott_url_option.unwrap(),
10199
&invehicle_digital_twin_address,
102100
)
103-
.await?;
101+
.await
102+
{
103+
Ok(()) => return Ok(()),
104+
Err(error) => {
105+
error!("Failed to register this service with Chariott: '{error}'");
106+
Err(error)?
107+
}
108+
};
109+
info!("This service is now registered with Chariott.");
110+
} else {
111+
info!("This service is not using Chariott.");
104112
}
105113

106114
server_future.await?;

samples/common/src/utils.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,14 @@ pub async fn retrieve_invehicle_digital_twin_url(
170170
// First try to use the one specified in the invehicle_digital_twin_url setting.
171171
// If it is not set, then go to Chariott to obtain it.
172172
let result = match invehicle_digital_twin_url {
173-
Some(value) => value,
173+
Some(value) => {
174+
info!("The URL for the in-vehicle digital twin service is specified in the settings file.");
175+
value
176+
},
174177
None => {
175178
match chariott_url {
176179
Some(value) => {
180+
info!("The URL for the in-vehicle digital twin service will be retrieved from Chariott.");
177181
match retry_async_based_on_status(30, Duration::from_secs(1), || discover_digital_twin_service_using_chariott(&value)).await {
178182
Ok(value) => value,
179183
Err(error) => Err(format!("Failed to discover the in-vehicle digital twin service's URL due to error: {error}"))?

0 commit comments

Comments
 (0)