(ctx context.Context)
| 326 | } |
| 327 | |
| 328 | func (r *Runner) sendHeartbeat(ctx context.Context) (*proto.UpdateJobResponse, error) { |
| 329 | ctx, span := r.startTrace(ctx, "updateHeartbeat") |
| 330 | defer span.End() |
| 331 | |
| 332 | r.mutex.Lock() |
| 333 | if !r.okToSend { |
| 334 | r.mutex.Unlock() |
| 335 | return nil, errUpdateSkipped |
| 336 | } |
| 337 | r.mutex.Unlock() |
| 338 | |
| 339 | // Skip sending a heartbeat if we've sent an update recently. |
| 340 | if lastUpdate := r.lastUpdate.Load(); lastUpdate != nil { |
| 341 | if time.Since(*lastUpdate) < r.updateInterval { |
| 342 | span.SetAttributes(attribute.Bool("heartbeat_skipped", true)) |
| 343 | return &proto.UpdateJobResponse{}, nil |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | return r.update(ctx, &proto.UpdateJobRequest{ |
| 348 | JobId: r.job.JobId, |
| 349 | }) |
| 350 | } |
| 351 | |
| 352 | func (r *Runner) update(ctx context.Context, u *proto.UpdateJobRequest) (*proto.UpdateJobResponse, error) { |
| 353 | ctx, cancel := context.WithTimeout(ctx, 30*time.Second) |
no test coverage detected