MCPcopy Index your code
hub / github.com/coder/coder / queueLog

Method queueLog

provisionerd/runner/runner.go:1159–1176  ·  view source on GitHub ↗

queueLog adds a log to the buffer and debounces a timer if one exists to flush the logs. It stores a maximum of 100 log lines before flushing as a safe-guard mechanism.

(ctx context.Context, log *proto.Log)

Source from the content-addressed store, hash-verified

1157// if one exists to flush the logs. It stores a maximum of
1158// 100 log lines before flushing as a safe-guard mechanism.
1159func (r *Runner) queueLog(ctx context.Context, log *proto.Log) {
1160 r.mutex.Lock()
1161 defer r.mutex.Unlock()
1162 r.queuedLogs = append(r.queuedLogs, log)
1163 if r.flushLogsTimer != nil {
1164 r.flushLogsTimer.Reset(r.logBufferInterval)
1165 return
1166 }
1167 // This can be configurable if there are a ton of logs.
1168 if len(r.queuedLogs) > 100 {
1169 // Flushing logs requires a lock, so this can happen async.
1170 go r.flushQueuedLogs(ctx)
1171 return
1172 }
1173 r.flushLogsTimer = time.AfterFunc(r.logBufferInterval, func() {
1174 r.flushQueuedLogs(ctx)
1175 })
1176}
1177
1178func (r *Runner) flushQueuedLogs(ctx context.Context) {
1179 r.mutex.Lock()

Callers 10

applyMethod · 0.95
initMethod · 0.95
doCleanFinishMethod · 0.95
doMethod · 0.95
runTemplateImportMethod · 0.95
commitQuotaMethod · 0.95
runWorkspaceBuildMethod · 0.95
planMethod · 0.95
graphMethod · 0.95

Calls 4

flushQueuedLogsMethod · 0.95
ResetMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected