File tree Expand file tree Collapse file tree
taurus-provider/src/providers/remote Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use std:: path:: Path ;
2- use std:: time:: Instant ;
2+ use std:: time:: { Duration , Instant } ;
33
44use clap:: Parser ;
55use log:: error;
@@ -207,7 +207,8 @@ async fn main() {
207207 return ;
208208 }
209209
210- let remote = NATSRemoteRuntime :: new ( client. clone ( ) ) ;
210+ let remote =
211+ NATSRemoteRuntime :: with_execution_result_timeout ( client. clone ( ) , Duration :: from_secs ( 30 ) ) ;
211212 let emitter = NATSRespondEmitter :: new ( client) ;
212213 let engine = ExecutionEngine :: new ( ) ;
213214
Original file line number Diff line number Diff line change @@ -11,13 +11,18 @@ use tucana::shared::NodeExecutionResult;
1111
1212pub struct NATSRemoteRuntime {
1313 client : Client ,
14+ execution_result_timeout : Duration ,
1415}
1516
16- const REMOTE_EXECUTION_RESULT_TIMEOUT : Duration = Duration :: from_secs ( 30 ) ;
17-
1817impl NATSRemoteRuntime {
19- pub fn new ( client : Client ) -> Self {
20- NATSRemoteRuntime { client }
18+ pub fn with_execution_result_timeout (
19+ client : Client ,
20+ execution_result_timeout : Duration ,
21+ ) -> Self {
22+ NATSRemoteRuntime {
23+ client,
24+ execution_result_timeout,
25+ }
2126 }
2227}
2328
@@ -64,7 +69,7 @@ impl RemoteRuntime for NATSRemoteRuntime {
6469 "Failed to receive any response messages from a remote runtime." ,
6570 ) ) ;
6671 }
67- match tokio:: time:: timeout ( REMOTE_EXECUTION_RESULT_TIMEOUT , self . client . flush ( ) ) . await {
72+ match tokio:: time:: timeout ( self . execution_result_timeout , self . client . flush ( ) ) . await {
6873 Ok ( Ok ( ( ) ) ) => { }
6974 Ok ( Err ( err) ) => {
7075 log:: error!(
@@ -90,8 +95,7 @@ impl RemoteRuntime for NATSRemoteRuntime {
9095 }
9196 }
9297
93- let message = match tokio:: time:: timeout ( REMOTE_EXECUTION_RESULT_TIMEOUT , sub. next ( ) ) . await
94- {
98+ let message = match tokio:: time:: timeout ( self . execution_result_timeout , sub. next ( ) ) . await {
9599 Ok ( Some ( message) ) => message,
96100 Ok ( None ) => {
97101 log:: error!( "RemoteRuntimeException: NATS reply subscription closed" ) ;
Original file line number Diff line number Diff line change @@ -31,7 +31,10 @@ pub async fn run() {
3131 let ( runtime_status_service, runtime_execution_service, mut runtime_status_heartbeat_task) =
3232 setup_dynamic_services_if_needed ( & config) . await ;
3333
34- let nats_remote = NATSRemoteRuntime :: new ( client. clone ( ) ) ;
34+ let nats_remote = NATSRemoteRuntime :: with_execution_result_timeout (
35+ client. clone ( ) ,
36+ Duration :: from_secs ( config. remote_runtime_timeout_secs ) ,
37+ ) ;
3538 let runtime_emitter = NATSRespondEmitter :: new ( client. clone ( ) ) ;
3639 let mut worker_task = worker:: spawn_worker (
3740 client,
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ pub struct Config {
3636
3737 /// Timeout in seconds for Aquila gRPC requests.
3838 pub aquila_grpc_request_timeout_secs : u64 ,
39+
40+ /// Timeout in seconds for remote runtime NATS flush and response waits.
41+ pub remote_runtime_timeout_secs : u64 ,
3942}
4043
4144/// Implementation for all relevant `Taurus` startup configurations
@@ -66,6 +69,7 @@ impl Config {
6669 "AQUILA_GRPC_REQUEST_TIMEOUT_SECS" ,
6770 10_u64 ,
6871 ) ,
72+ remote_runtime_timeout_secs : env_with_default ( "REMOTE_RUNTIME_TIMEOUT_SECS" , 30_u64 ) ,
6973 }
7074 }
7175}
Original file line number Diff line number Diff line change @@ -103,3 +103,4 @@ Set `MODE=dynamic` when the IDE is required/needed.
103103| ` RUNTIME_STATUS_UPDATE_INTERVAL_SECONDS ` | Interval (in seconds) of updating the current runtime status. | ` 30s ` |
104104| ` AQUILA_GRPC_CONNECT_TIMEOUT_SECS ` | Timeout in seconds for establishing Aquila gRPC channels. | ` 2s ` |
105105| ` AQUILA_GRPC_REQUEST_TIMEOUT_SECS ` | Timeout in seconds for Aquila gRPC requests. | ` 10s ` |
106+ | ` REMOTE_RUNTIME_TIMEOUT_SECS ` | Timeout in seconds for remote runtime NATS flush and response waits. | ` 30s ` |
You can’t perform that action at this time.
0 commit comments