@@ -210,7 +210,12 @@ func (f *FakeAgentAPI) UpdateStats(ctx context.Context, req *agentproto.UpdateSt
210
210
f .logger .Debug (ctx , "update stats called" , slog .F ("req" , req ))
211
211
// empty request is sent to get the interval; but our tests don't want empty stats requests
212
212
if req .Stats != nil {
213
- f .statsCh <- req .Stats
213
+ select {
214
+ case <- ctx .Done ():
215
+ return nil , ctx .Err ()
216
+ case f .statsCh <- req .Stats :
217
+ // OK!
218
+ }
214
219
}
215
220
return & agentproto.UpdateStatsResponse {ReportInterval : durationpb .New (statsInterval )}, nil
216
221
}
@@ -233,17 +238,25 @@ func (f *FakeAgentAPI) UpdateLifecycle(_ context.Context, req *agentproto.Update
233
238
234
239
func (f * FakeAgentAPI ) BatchUpdateAppHealths (ctx context.Context , req * agentproto.BatchUpdateAppHealthRequest ) (* agentproto.BatchUpdateAppHealthResponse , error ) {
235
240
f .logger .Debug (ctx , "batch update app health" , slog .F ("req" , req ))
236
- f .appHealthCh <- req
237
- return & agentproto.BatchUpdateAppHealthResponse {}, nil
241
+ select {
242
+ case <- ctx .Done ():
243
+ return nil , ctx .Err ()
244
+ case f .appHealthCh <- req :
245
+ return & agentproto.BatchUpdateAppHealthResponse {}, nil
246
+ }
238
247
}
239
248
240
249
func (f * FakeAgentAPI ) AppHealthCh () <- chan * agentproto.BatchUpdateAppHealthRequest {
241
250
return f .appHealthCh
242
251
}
243
252
244
- func (f * FakeAgentAPI ) UpdateStartup (_ context.Context , req * agentproto.UpdateStartupRequest ) (* agentproto.Startup , error ) {
245
- f .startupCh <- req .GetStartup ()
246
- return req .GetStartup (), nil
253
+ func (f * FakeAgentAPI ) UpdateStartup (ctx context.Context , req * agentproto.UpdateStartupRequest ) (* agentproto.Startup , error ) {
254
+ select {
255
+ case <- ctx .Done ():
256
+ return nil , ctx .Err ()
257
+ case f .startupCh <- req .GetStartup ():
258
+ return req .GetStartup (), nil
259
+ }
247
260
}
248
261
249
262
func (f * FakeAgentAPI ) GetMetadata () map [string ]agentsdk.Metadata {
0 commit comments