-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathclear_ended_tasks_task.go
54 lines (41 loc) · 1.04 KB
/
clear_ended_tasks_task.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package tasks
import (
"context"
"time"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/empty"
"github.com/ydb-platform/nbs/cloud/tasks/storage"
)
////////////////////////////////////////////////////////////////////////////////
type clearEndedTasksTask struct {
storage storage.Storage
expirationTimeout time.Duration
limit int
}
func (t *clearEndedTasksTask) Save() ([]byte, error) {
return nil, nil
}
func (t *clearEndedTasksTask) Load(_, _ []byte) error {
return nil
}
func (t *clearEndedTasksTask) Run(
ctx context.Context,
execCtx ExecutionContext,
) error {
endedBefore := time.Now().Add(-t.expirationTimeout)
return t.storage.ClearEndedTasks(ctx, endedBefore, t.limit)
}
func (t *clearEndedTasksTask) Cancel(
ctx context.Context,
execCtx ExecutionContext,
) error {
return nil
}
func (t *clearEndedTasksTask) GetMetadata(
ctx context.Context,
) (proto.Message, error) {
return &empty.Empty{}, nil
}
func (t *clearEndedTasksTask) GetResponse() proto.Message {
return &empty.Empty{}
}