Skip to content

Commit 38a80ba

Browse files
Merge pull request #364 from code0-tech/#363-sagittarius-grpc-timeout-config
made sagittarius rpc timeout configurable
2 parents dbfb2ca + 36727ba commit 38a80ba

6 files changed

Lines changed: 41 additions & 19 deletions

File tree

docs/installation.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ Aquila configuration is split into shared variables and mode-specific variables.
9090
| `GRPC_PORT` | Port for the Aquila gRPC server. | `8081` |
9191
| `WITH_HEALTH_SERVICE` | Enables the gRPC health service when set to `true`. | `false` |
9292
| `SERVICE_CONFIG_PATH` | Path to the JSON service-configuration file used for runtime/action authorization and default action configs. | `./service.configuration.json` |
93-
| `RUNTIME_STATUS_NOT_RESPONDING_AFTER_SECS` | Seconds a runtime serivce will be marked as `not_responding` when no hearbeat was recieved. | `15s` |
94-
| `RUNTIME_STATUS_STOPPED_AFTER_NOT_RESPONDING_SECS` | Seconds a runtime serivce will be marked as `stopped` when no hearbeat was recieved. | `30s` |
95-
| `RUNTIME_STATUS_MONITOR_INTERVAL_SECS` | Interval in which the heartbeat of the services will be flagged/checked. | `3s` |
93+
| `RUNTIME_STATUS_NOT_RESPONDING_AFTER_SECS` | Seconds before a runtime service is marked as `not_responding` when no heartbeat was received. | `90s` |
94+
| `RUNTIME_STATUS_STOPPED_AFTER_NOT_RESPONDING_SECS` | Additional seconds before a non-responding runtime service is marked as `stopped`. | `180s` |
95+
| `RUNTIME_STATUS_MONITOR_INTERVAL_SECS` | Interval in which runtime service heartbeats are checked. | `30s` |
96+
| `SAGITTARIUS_UNARY_RPC_TIMEOUT_SECS` | Timeout in seconds for unary RPC calls from Aquila to Sagittarius. | `5s` |
9697

9798
### Static Mode
9899

src/configuration/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ pub struct Config {
5050

5151
/// Interval in seconds for the runtime status timeout monitor loop.
5252
pub runtime_status_monitor_interval_secs: u64,
53+
54+
/// Timeout in seconds for unary RPC calls from Aquila to Sagittarius.
55+
pub sagittarius_unary_rpc_timeout_secs: u64,
5356
}
5457

5558
/// Implementation for all relevant `Aquila` startup configurations
@@ -97,6 +100,10 @@ impl Config {
97100
"RUNTIME_STATUS_MONITOR_INTERVAL_SECS",
98101
30_u64,
99102
),
103+
sagittarius_unary_rpc_timeout_secs: env_with_default(
104+
"SAGITTARIUS_UNARY_RPC_TIMEOUT_SECS",
105+
5_u64,
106+
),
100107
}
101108
}
102109

src/sagittarius/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
use std::time::Duration;
2-
31
pub mod flow_service_client_impl;
42
pub mod module_service_client_impl;
53
pub mod retry;
64
pub mod runtime_status_service_client_impl;
75
pub mod test_execution_client_impl;
8-
9-
pub(crate) const SAGITTARIUS_UNARY_RPC_TIMEOUT: Duration = Duration::from_secs(5);

src/sagittarius/module_service_client_impl.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
use crate::authorization::authorization::get_authorization_metadata;
2-
use crate::sagittarius::SAGITTARIUS_UNARY_RPC_TIMEOUT;
2+
use std::time::Duration;
33
use tonic::transport::Channel;
44
use tonic::{Extensions, Request};
55

66
pub struct SagittariusModuleServiceClient {
77
client: tucana::sagittarius::module_service_client::ModuleServiceClient<Channel>,
88
token: String,
9+
unary_rpc_timeout: Duration,
910
}
1011

1112
impl SagittariusModuleServiceClient {
12-
pub fn new(channel: Channel, token: String) -> Self {
13+
pub fn new(channel: Channel, token: String, unary_rpc_timeout: Duration) -> Self {
1314
let client = tucana::sagittarius::module_service_client::ModuleServiceClient::new(channel);
1415

15-
Self { client, token }
16+
Self {
17+
client,
18+
token,
19+
unary_rpc_timeout,
20+
}
1621
}
1722

1823
pub async fn update_modules(
@@ -32,7 +37,7 @@ impl SagittariusModuleServiceClient {
3237
modules: modules_update_request.modules,
3338
},
3439
);
35-
request.set_timeout(SAGITTARIUS_UNARY_RPC_TIMEOUT);
40+
request.set_timeout(self.unary_rpc_timeout);
3641

3742
match self.client.update(request).await {
3843
Ok(response) => {

src/sagittarius/runtime_status_service_client_impl.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
use crate::authorization::authorization::get_authorization_metadata;
2-
use crate::sagittarius::SAGITTARIUS_UNARY_RPC_TIMEOUT;
2+
use std::time::Duration;
33
use tonic::{Extensions, Request, transport::Channel};
44
use tucana::sagittarius::runtime_status_service_client::RuntimeStatusServiceClient;
55

66
pub struct SagittariusRuntimeStatusServiceClient {
77
client: RuntimeStatusServiceClient<Channel>,
88
token: String,
9+
unary_rpc_timeout: Duration,
910
}
1011

1112
impl SagittariusRuntimeStatusServiceClient {
12-
pub fn new(channel: Channel, token: String) -> Self {
13+
pub fn new(channel: Channel, token: String, unary_rpc_timeout: Duration) -> Self {
1314
let client = RuntimeStatusServiceClient::new(channel);
14-
Self { client, token }
15+
Self {
16+
client,
17+
token,
18+
unary_rpc_timeout,
19+
}
1520
}
1621

1722
pub async fn update_runtime_status(
@@ -26,7 +31,7 @@ impl SagittariusRuntimeStatusServiceClient {
2631
status: runtime_status_request.status,
2732
},
2833
);
29-
request.set_timeout(SAGITTARIUS_UNARY_RPC_TIMEOUT);
34+
request.set_timeout(self.unary_rpc_timeout);
3035

3136
let response = match self.client.update(request).await {
3237
Ok(response) => {

src/server/dynamic_server.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub struct AquilaDynamicServer {
4040
runtime_status_not_responding_after_secs: u64,
4141
runtime_status_stopped_after_not_responding_secs: u64,
4242
runtime_status_monitor_interval_secs: u64,
43+
sagittarius_unary_rpc_timeout: Duration,
4344
}
4445

4546
impl AquilaDynamicServer {
@@ -83,20 +84,27 @@ impl AquilaDynamicServer {
8384
runtime_status_monitor_interval_secs: config
8485
.runtime_status_monitor_interval_secs
8586
.clone(),
87+
sagittarius_unary_rpc_timeout: Duration::from_secs(
88+
config.sagittarius_unary_rpc_timeout_secs,
89+
),
8690
}
8791
}
8892

8993
pub async fn start(&self) -> Result<(), tonic::transport::Error> {
9094
let module_service = Arc::new(Mutex::new(SagittariusModuleServiceClient::new(
9195
self.channel.clone(),
9296
self.token.clone(),
97+
self.sagittarius_unary_rpc_timeout,
9398
)));
9499

95100
info!("ModuleService started");
96101

97-
let runtime_status_service = Arc::new(Mutex::new(
98-
SagittariusRuntimeStatusServiceClient::new(self.channel.clone(), self.token.clone()),
99-
));
102+
let runtime_status_service =
103+
Arc::new(Mutex::new(SagittariusRuntimeStatusServiceClient::new(
104+
self.channel.clone(),
105+
self.token.clone(),
106+
self.sagittarius_unary_rpc_timeout,
107+
)));
100108

101109
info!("RuntimeStatusService started");
102110

@@ -108,7 +116,7 @@ impl AquilaDynamicServer {
108116
module_service.clone(),
109117
self.service_configuration.clone(),
110118
);
111-
let runtime_status_server = AquilaRuntimeStatusServiceServer::new(
119+
let runtime_status_server = AquilaRuntimeStatusServiceServer::new(
112120
runtime_status_service.clone(),
113121
self.service_configuration.clone(),
114122
Duration::from_secs(self.runtime_status_not_responding_after_secs.clone()),

0 commit comments

Comments
 (0)