MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / RecycleTask

Method RecycleTask

pkg/funclet/task.go:33–60  ·  view source on GitHub ↗
(stopCh <-chan struct{},  finishCh chan struct{})

Source from the content-addressed store, hash-verified

31)
32
33func (f *Funclet) RecycleTask(stopCh <-chan struct{}, finishCh chan struct{}) {
34 ticker := time.NewTicker(30 * time.Second)
35 defer ticker.Stop()
36 for {
37 select {
38 case <-stopCh:
39 f.logger.Infof("funclet stopped")
40 // graceful exit task
41 // ...
42 list, _ := f.RuntimeClient.ListContainers()
43 for _, container := range list {
44 ID := container.ID
45 f.RuntimeClient.ThawContainer(ID)
46 }
47 return
48 case <-ticker.C:
49 taskID := id.GetTaskID()
50 taskLogger := f.logger.WithField("task-id", taskID)
51 taskLogger.Infof("start recycle task")
52 defer taskLogger.Infof("finish recycle task")
53 if err := f.tmpRecycleTask(taskLogger); err != nil {
54 taskLogger.Errorf("tmp recycle task failed: %s", err)
55 }
56 // other recycle task
57 // ...
58 }
59 }
60}
61
62func (f *Funclet) tmpRecycleTask(tlog *logs.Logger) (err error) {
63 tlog.Infof("[tmp recycle task] start task")

Callers 1

InitFuncletFunction · 0.80

Calls 7

tmpRecycleTaskMethod · 0.95
GetTaskIDFunction · 0.92
InfofMethod · 0.80
WithFieldMethod · 0.80
ErrorfMethod · 0.80
ListContainersMethod · 0.65
ThawContainerMethod · 0.65

Tested by

no test coverage detected