MCPcopy
hub / github.com/derailed/k9s / Add

Method Add

internal/pool.go:51–64  ·  view source on GitHub ↗
(job jobFn)

Source from the content-addressed store, hash-verified

49}
50
51func (p *WorkerPool) Add(job jobFn) {
52 p.semC <- struct{}{}
53 p.wg.Add(1)
54 go func(ctx context.Context, wg *sync.WaitGroup, semC <-chan struct{}, errC chan<- error) {
55 defer func() {
56 <-semC
57 wg.Done()
58 }()
59 if err := job(ctx); err != nil {
60 slog.Error("Worker error", slogs.Error, err)
61 errC <- err
62 }
63 }(p.ctx, &p.wg, p.semC, p.errC)
64}
65
66func (p *WorkerPool) Drain() []error {
67 if p.cancelFn != nil {

Callers 2

TestWorkerPoolPlainFunction · 0.95
TestWorkerPoolWithErrorFunction · 0.95

Calls 2

AddMethod · 0.65
ErrorMethod · 0.45

Tested by 2

TestWorkerPoolPlainFunction · 0.76
TestWorkerPoolWithErrorFunction · 0.76