MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / worker

Method worker

worker/queue.go:212–234  ·  view source on GitHub ↗

worker loops forever, running queued tasks one at a time. Any returned errors are logged.

()

Source from the content-addressed store, hash-verified

210
211// worker loops forever, running queued tasks one at a time. Any returned errors are logged.
212func (t *tasks) worker() {
213 shouldCleanup := time.Tick(time.Hour)
214
215 for {
216 // If the server is shutting down, return immediately. Else, fetch a task from the queue.
217 var task taskRequest
218 select {
219 case <-x.ServerCloser.HasBeenClosed():
220 if err := t.log.Close(); err != nil {
221 glog.Warningf("error closing log file: %v", err)
222 }
223 return
224 case <-shouldCleanup:
225 t.cleanup()
226 case task = <-t.queue:
227 if err := t.run(task); err != nil {
228 glog.Errorf("task %#x: failed: %s", task.id, err)
229 } else {
230 glog.Infof("task %#x: completed successfully", task.id)
231 }
232 }
233 }
234}
235
236func (t *tasks) run(task taskRequest) error {
237 // Fetch the task from the log. If the task isn't found, this means it has expired (older than

Callers 1

InitTasksFunction · 0.80

Calls 6

cleanupMethod · 0.95
runMethod · 0.95
WarningfMethod · 0.80
InfofMethod · 0.80
CloseMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected