MCPcopy
hub / github.com/esm-dev/esm.sh / Add

Method Add

server/build_queue.go:47–72  ·  view source on GitHub ↗

Add adds a new build task to the queue.

(ctx *BuildContext)

Source from the content-addressed store, hash-verified

45
46// Add adds a new build task to the queue.
47func (q *BuildQueue) Add(ctx *BuildContext) chan BuildOutput {
48 q.lock.Lock()
49 defer q.lock.Unlock()
50
51 ch := make(chan BuildOutput, 1)
52
53 task, ok := q.tasks[ctx.Path()]
54 if ok {
55 task.waitChans = append(task.waitChans, ch)
56 return ch
57 }
58
59 task = &BuildTask{
60 ctx: ctx,
61 createdAt: time.Now(),
62 waitChans: []chan BuildOutput{ch},
63 }
64 ctx.status = "pending"
65
66 q.pending.PushBack(task)
67 q.tasks[ctx.Path()] = task
68
69 q.startSchedulerLocked()
70
71 return ch
72}
73
74func (q *BuildQueue) Snapshot() []map[string]any {
75 q.lock.Lock()

Callers 15

ToNpmPackageMethod · 0.80
addImportMethod · 0.80
customLandingPageFunction · 0.80
esmRouterFunction · 0.80
setCacheItemFunction · 0.80
withCacheFunction · 0.80
withLRUCacheFunction · 0.80
GetMethod · 0.80
PutMethod · 0.80
resolveBuildArgsFunction · 0.80
walkDepsFunction · 0.80
buildModuleMethod · 0.80

Calls 2

startSchedulerLockedMethod · 0.95
PathMethod · 0.80

Tested by

no test coverage detected