MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / newContext

Method newContext

pkg/queue/queue.go:212–219  ·  view source on GitHub ↗

newContext creates a new context for a new Task iteration.

(t Task)

Source from the content-addressed store, hash-verified

210
211// newContext creates a new context for a new Task iteration.
212func (q *queue) newContext(t Task) context.Context {
213 l := q.logger.CopyWithPrefix(fmt.Sprintf("[Cid: %s TaskID: %d Queue: %s]", t.CorrelationID(), t.ID(), q.name))
214 ctx := q.dep.ForkWithLogger(q.rootCtx, l)
215 ctx = context.WithValue(ctx, logging.CorrelationIDCtx{}, t.CorrelationID())
216 ctx = context.WithValue(ctx, logging.LoggerCtx{}, l)
217 ctx = context.WithValue(ctx, inventory.UserCtx{}, t.Owner())
218 return ctx
219}
220
221func (q *queue) work(t Task) {
222 ctx := q.newContext(t)

Callers 1

workMethod · 0.95

Calls 5

CopyWithPrefixMethod · 0.65
CorrelationIDMethod · 0.65
IDMethod · 0.65
ForkWithLoggerMethod · 0.65
OwnerMethod · 0.65

Tested by

no test coverage detected