| 393 | } |
| 394 | |
| 395 | func (i *instanceManager) Update(instance dbCommon.ChangePayload) error { |
| 396 | if !i.running.Load() { |
| 397 | return runnerErrors.NewBadRequestError("instance manager is not running") |
| 398 | } |
| 399 | |
| 400 | timer := time.NewTimer(10 * time.Second) |
| 401 | defer timer.Stop() |
| 402 | |
| 403 | slog.DebugContext(i.ctx, "sending update to instance manager") |
| 404 | select { |
| 405 | case i.updates <- instance: |
| 406 | case <-i.quit: |
| 407 | return nil |
| 408 | case <-i.ctx.Done(): |
| 409 | return nil |
| 410 | case <-timer.C: |
| 411 | return fmt.Errorf("timeout while sending update to instance manager") |
| 412 | } |
| 413 | return nil |
| 414 | } |
| 415 | |
| 416 | func (i *instanceManager) updatesLoop() { |
| 417 | defer i.Stop() |