@@ -57,7 +57,7 @@ impl DaemonRuntimeService {
5757 tracing:: info!( daemon_id = %daemon_id, "Checking for work..." ) ;
5858
5959 let path = format ! ( "/api/daemons/{}/request-work" , daemon_id) ;
60- let ( payload , cancel_current_session ) : ( Option < DiscoveryUpdatePayload > , bool ) = self
60+ let result : Result < ( Option < DiscoveryUpdatePayload > , bool ) , _ > = self
6161 . api_client
6262 . post (
6363 & path,
@@ -68,28 +68,35 @@ impl DaemonRuntimeService {
6868 } ,
6969 "Failed to request work" ,
7070 )
71- . await ?;
72-
73- if !cancel_current_session && payload. is_none ( ) {
74- tracing:: info!( daemon_id = %daemon_id, "No work available at this time" ) ;
75- }
76-
77- if cancel_current_session {
78- tracing:: info!( daemon_id = %daemon_id, "Received cancellation request from server" ) ;
79- self . discovery_manager . cancel_current_session ( ) . await ;
80- }
81-
82- if let Some ( payload) = payload
83- && !self . discovery_manager . is_discovery_running ( ) . await
84- {
85- tracing:: info!(
86- daemon_id = %daemon_id,
87- session_id = %payload. session_id,
88- "Received discovery session from server"
89- ) ;
90- self . discovery_manager
91- . initiate_session ( payload. into ( ) )
92- . await ;
71+ . await ;
72+
73+ match result {
74+ Ok ( ( payload, cancel_current_session) ) => {
75+ if !cancel_current_session && payload. is_none ( ) {
76+ tracing:: info!( daemon_id = %daemon_id, "No work available at this time" ) ;
77+ }
78+
79+ if cancel_current_session {
80+ tracing:: info!( daemon_id = %daemon_id, "Received cancellation request from server" ) ;
81+ self . discovery_manager . cancel_current_session ( ) . await ;
82+ }
83+
84+ if let Some ( payload) = payload
85+ && !self . discovery_manager . is_discovery_running ( ) . await
86+ {
87+ tracing:: info!(
88+ daemon_id = %daemon_id,
89+ session_id = %payload. session_id,
90+ "Received discovery session from server"
91+ ) ;
92+ self . discovery_manager
93+ . initiate_session ( payload. into ( ) )
94+ . await ;
95+ }
96+ }
97+ Err ( e) => {
98+ tracing:: error!( daemon_id = %daemon_id, error = %e, "Failed to request work" ) ;
99+ }
93100 }
94101 }
95102 }
@@ -113,9 +120,9 @@ impl DaemonRuntimeService {
113120 }
114121
115122 let path = format ! ( "/api/daemons/{}/heartbeat" , daemon_id) ;
116- let _ : ( ) = self
123+ match self
117124 . api_client
118- . post_no_data (
125+ . post_no_data :: < _ > (
119126 & path,
120127 & DaemonHeartbeatPayload {
121128 url : url. clone ( ) ,
@@ -124,10 +131,17 @@ impl DaemonRuntimeService {
124131 } ,
125132 "Heartbeat failed" ,
126133 )
127- . await ?;
128-
129- if let Err ( e) = self . config . update_heartbeat ( ) . await {
130- tracing:: warn!( "Failed to update heartbeat timestamp: {}" , e) ;
134+ . await
135+ {
136+ Ok ( _) => {
137+ tracing:: info!( daemon_id = %daemon_id, "Heartbeat sent" ) ;
138+ if let Err ( e) = self . config . update_heartbeat ( ) . await {
139+ tracing:: warn!( "Failed to update heartbeat timestamp: {}" , e) ;
140+ }
141+ }
142+ Err ( e) => {
143+ tracing:: error!( daemon_id = %daemon_id, error = %e, "Heartbeat failed" ) ;
144+ }
131145 }
132146 }
133147 }
0 commit comments