(ctx context.Context, message []byte, err error)
| 326 | } |
| 327 | |
| 328 | func (a *Acquirer) jobPosted(ctx context.Context, message []byte, err error) { |
| 329 | if xerrors.Is(err, pubsub.ErrDroppedMessages) { |
| 330 | a.logger.Warn(a.ctx, "pubsub may have dropped job postings") |
| 331 | a.clearOrPendAll() |
| 332 | return |
| 333 | } |
| 334 | if err != nil { |
| 335 | a.logger.Warn(a.ctx, "unhandled pubsub error", slog.Error(err)) |
| 336 | return |
| 337 | } |
| 338 | posting := provisionerjobs.JobPosting{} |
| 339 | err = json.Unmarshal(message, &posting) |
| 340 | if err != nil { |
| 341 | a.logger.Error(a.ctx, "unable to parse job posting", |
| 342 | slog.F("message", string(message)), |
| 343 | slog.Error(err), |
| 344 | ) |
| 345 | return |
| 346 | } |
| 347 | a.logger.Debug(ctx, "got job posting", slog.F("posting", posting)) |
| 348 | |
| 349 | a.mu.Lock() |
| 350 | defer a.mu.Unlock() |
| 351 | for _, d := range a.q { |
| 352 | if d.contains(posting) { |
| 353 | a.clearOrPendLocked(d) |
| 354 | // we only need to wake up a single domain since there is only one |
| 355 | // new job available |
| 356 | return |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | func (a *Acquirer) clearOrPendAll() { |
| 362 | a.mu.Lock() |
nothing calls this directly
no test coverage detected