Skip to content

Commit fca93bc

Browse files
committed
feat: added grpc health server
1 parent 3448a7c commit fca93bc

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

crates/base/src/runner.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use crate::{
66
use code0_flow::flow_definition::FlowUpdateService;
77
use std::sync::Arc;
88
use tokio::sync::broadcast;
9+
use tonic::transport::Server;
10+
use tonic_health::pb::health_server::HealthServer;
911

1012
/*
1113
* The ServerRunner is intended to be used as a wrapper around a server implementation.
@@ -67,6 +69,19 @@ impl<C: LoadConfig> ServerRunner<C> {
6769
}
6870

6971
if config.is_monitored {
72+
let health_service =
73+
code0_flow::flow_health::HealthService::new(config.nats_url.clone());
74+
75+
if let Ok(address) = format!("127.0.0.1:{}", config.grpc_port).parse() {
76+
println!("Health server started at {}", address);
77+
let _ = Server::builder()
78+
.add_service(HealthServer::new(health_service))
79+
.serve(address)
80+
.await;
81+
} else {
82+
println!("Failed to parse address, starting without health server");
83+
}
84+
7085
todo!("Start the HealthServer");
7186
}
7287

crates/base/src/store.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ impl AdapterStore {
2525

2626
let jetstream = async_nats::jetstream::new(client.clone());
2727

28-
let res = jetstream
28+
let _ = jetstream
2929
.create_key_value(Config {
3030
bucket: bucket.clone(),
3131
..Default::default()
3232
})
3333
.await;
3434

35-
println!("{:?}", &res);
36-
3735
let kv = match jetstream.get_key_value(bucket).await {
3836
Ok(kv) => kv,
3937
Err(err) => panic!("Failed to get key-value store: {}", err),

0 commit comments

Comments
 (0)