Skip to content

Commit b4d953d

Browse files
committed
feat: added runtime usage client
1 parent b8fb7d5 commit b4d953d

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

crates/taurus/src/client/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pub mod runtime_status;
2+
pub mod runtime_usage;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use code0_flow::flow_service::retry::create_channel_with_retry;
2+
use tonic::transport::Channel;
3+
use tucana::{
4+
aquila::{RuntimeUsageRequest, runtime_usage_service_client::RuntimeUsageServiceClient},
5+
shared::RuntimeUsage,
6+
};
7+
8+
pub struct TaurusRuntimeUsageService {
9+
channel: Channel,
10+
}
11+
12+
impl TaurusRuntimeUsageService {
13+
pub async fn from_url(aquila_url: String) -> Self {
14+
let channel = create_channel_with_retry("Aquila", aquila_url).await;
15+
TaurusRuntimeUsageService { channel }
16+
}
17+
18+
pub async fn update_runtime_usage(&self, runtime_usage: RuntimeUsage) {
19+
log::info!("Updating the current Runtime Status!");
20+
let mut client = RuntimeUsageServiceClient::new(self.channel.clone());
21+
22+
let request = RuntimeUsageRequest {
23+
runtime_usage: vec![runtime_usage],
24+
};
25+
26+
match client.update(request).await {
27+
Ok(response) => {
28+
log::info!(
29+
"Was the update of the RuntimeStatus accepted by Sagittarius? {}",
30+
response.into_inner().success
31+
);
32+
}
33+
Err(err) => {
34+
log::error!("Failed to update RuntimeStatus: {:?}", err);
35+
}
36+
}
37+
}
38+
}
39+

0 commit comments

Comments
 (0)