MCPcopy
hub / github.com/caddyserver/certmagic / Submit

Method Submit

async.go:34–52  ·  view source on GitHub ↗

Submit enqueues the given job with the given name. If name is non-empty and a job with the same name is already enqueued or running, this is a no-op. If name is empty, no duplicate prevention will occur. The job manager will then run this job as soon as it is able.

(logger *zap.Logger, name string, job func() error)

Source from the content-addressed store, hash-verified

32// no-op. If name is empty, no duplicate prevention will occur. The job
33// manager will then run this job as soon as it is able.
34func (jm *jobManager) Submit(logger *zap.Logger, name string, job func() error) {
35 jm.mu.Lock()
36 defer jm.mu.Unlock()
37 if jm.names == nil {
38 jm.names = make(map[string]struct{})
39 }
40 if name != "" {
41 // prevent duplicate jobs
42 if _, ok := jm.names[name]; ok {
43 return
44 }
45 jm.names[name] = struct{}{}
46 }
47 jm.queue = append(jm.queue, namedJob{name, job, logger})
48 if jm.activeWorkers < jm.maxConcurrentJobs {
49 jm.activeWorkers++
50 go jm.worker()
51 }
52}
53
54func (jm *jobManager) worker() {
55 defer func() {

Callers 3

queueRenewalTaskMethod · 0.80
manageOneMethod · 0.80

Calls 3

workerMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65

Tested by 1