-
Notifications
You must be signed in to change notification settings - Fork 14
/
repair_dequeue.go
53 lines (41 loc) · 960 Bytes
/
repair_dequeue.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
package op
import (
"context"
"github.com/cybozu-go/cke"
)
type repairDequeueOp struct {
finished bool
entry *cke.RepairQueueEntry
}
func RepairDequeueOp(entry *cke.RepairQueueEntry) cke.Operator {
return &repairDequeueOp{
entry: entry,
}
}
func (o *repairDequeueOp) Name() string {
return "repair-dequeue"
}
func (o *repairDequeueOp) NextCommand() cke.Commander {
if o.finished {
return nil
}
o.finished = true
return repairDequeueCommand{
entry: o.entry,
}
}
func (o *repairDequeueOp) Targets() []string {
return []string{o.entry.Address}
}
type repairDequeueCommand struct {
entry *cke.RepairQueueEntry
}
func (c repairDequeueCommand) Run(ctx context.Context, inf cke.Infrastructure, leaderKey string) error {
return inf.Storage().DeleteRepairsEntry(ctx, leaderKey, c.entry.Index)
}
func (c repairDequeueCommand) Command() cke.Command {
return cke.Command{
Name: "repairDequeueCommand",
Target: c.entry.Address,
}
}