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

Method acquire

enterprise/tailnet/pgcoord.go:1567–1573  ·  view source on GitHub ↗

acquire blocks until a work item is available and returns it. After acquiring a key, the worker MUST call done() with the same key to mark it complete and allow new pending work to be acquired for the key.

()

Source from the content-addressed store, hash-verified

1565// acquiring a key, the worker MUST call done() with the same key to mark
1566// it complete and allow new pending work to be acquired for the key.
1567func (q *workQ[K]) acquire() (key K, err error) {
1568 items, err := q.acquireBatch(1)
1569 if err != nil {
1570 return key, err
1571 }
1572 return items[0], nil
1573}
1574
1575// done marks the key completed; MUST be called after acquire() for each key.
1576func (q *workQ[K]) done(keys ...K) {

Callers 5

TestAcquireJobFunction · 0.80
workerMethod · 0.80
workerMethod · 0.80

Calls 1

acquireBatchMethod · 0.95

Tested by 3

TestAcquireJobFunction · 0.64