@@ -22,17 +22,20 @@ pub struct DracoRuntimeStatusService {
2222const MAX_BACKOFF : u64 = 2000 * 60 ;
2323const MAX_RETRIES : i8 = 10 ;
2424
25- // Will create a channel and retry if its not possible
26- pub async fn create_channel_with_retry ( channel_name : & str , url : String ) -> Channel {
25+ pub async fn create_channel_with_retry (
26+ channel_name : & str ,
27+ url : String ,
28+ connect_timeout : std:: time:: Duration ,
29+ request_timeout : std:: time:: Duration ,
30+ ) -> Channel {
2731 let mut backoff = 100 ;
2832 let mut retries = 0 ;
2933
3034 loop {
3135 let channel = match Endpoint :: from_shared ( url. clone ( ) ) {
3236 Ok ( c) => {
3337 log:: debug!( "Creating a new endpoint for the: {} Service" , channel_name) ;
34- c. connect_timeout ( std:: time:: Duration :: from_secs ( 2 ) )
35- . timeout ( std:: time:: Duration :: from_secs ( 10 ) )
38+ c. connect_timeout ( connect_timeout) . timeout ( request_timeout)
3639 }
3740 Err ( err) => {
3841 panic ! (
@@ -67,8 +70,15 @@ pub async fn create_channel_with_retry(channel_name: &str, url: String) -> Chann
6770 }
6871}
6972impl DracoRuntimeStatusService {
70- pub async fn from_url ( aquila_url : String , aquila_token : String , identifier : String ) -> Self {
71- let channel = create_channel_with_retry ( "Aquila" , aquila_url) . await ;
73+ pub async fn from_url (
74+ aquila_url : String ,
75+ aquila_token : String ,
76+ identifier : String ,
77+ connect_timeout : std:: time:: Duration ,
78+ request_timeout : std:: time:: Duration ,
79+ ) -> Self {
80+ let channel =
81+ create_channel_with_retry ( "Aquila" , aquila_url, connect_timeout, request_timeout) . await ;
7282 Self :: new ( channel, identifier, aquila_token)
7383 }
7484
0 commit comments