-
Notifications
You must be signed in to change notification settings - Fork 1
/
kcl.go
47 lines (35 loc) · 817 Bytes
/
kcl.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
package kcl
import (
"fmt"
"os"
)
// Run ...
func Run(processor RecordProcessor) {
checkpointer := &Checkpointer{}
for {
msg := readMessage()
if msg == nil {
break
}
var err error
switch {
case msg.Action == "processRecords":
err = processor.ProcessRecords(msg.Records, checkpointer)
case msg.Action == "initialize":
err = processor.Initialize(*msg.ShardID)
case msg.Action == "leaseLost":
err = processor.LeaseLost()
case msg.Action == "shardEnded":
err = processor.ShardEnded(checkpointer)
case msg.Action == "shutdownRequested":
err = processor.ShutdownRequested(checkpointer)
default:
err = fmt.Errorf("Unsupported KCL action: %s", msg.Action)
}
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
writeStatus(msg.Action)
}
}