MCPcopy Create free account
hub / github.com/coder/coder / jobPosted

Method jobPosted

coderd/provisionerdserver/acquirer.go:328–359  ·  view source on GitHub ↗
(ctx context.Context, message []byte, err error)

Source from the content-addressed store, hash-verified

326}
327
328func (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
361func (a *Acquirer) clearOrPendAll() {
362 a.mu.Lock()

Callers

nothing calls this directly

Calls 8

clearOrPendAllMethod · 0.95
clearOrPendLockedMethod · 0.95
containsMethod · 0.80
IsMethod · 0.45
ErrorMethod · 0.45
UnmarshalMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected