This repository has been archived by the owner on May 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
86 lines (81 loc) · 1.8 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
import (
"os"
"strings"
"github.com/scoiatael/archai/actions"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "archai"
app.Usage = "eventstore replacement"
app.Version = Version
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "migrate",
Usage: "Migrate Cassandra on startup?",
},
cli.BoolFlag{
Name: "dev-logger",
Usage: "Enable dev logger",
},
cli.StringFlag{
Name: "keyspace",
Value: "archai",
Usage: "Cassandra keyspace to operate in",
},
cli.StringFlag{
Name: "hosts",
Value: "127.0.0.1",
Usage: "Comma-separated list of Cassandra hosts",
},
cli.StringFlag{
Name: "listen",
Value: "127.0.0.1",
Usage: "Address to listen on",
},
cli.StringFlag{
Name: "telemetry",
Value: "127.0.0.1",
Usage: "Address to send metrics to",
},
cli.Int64Flag{
Name: "port",
Value: 8080,
Usage: "Port to listen on",
},
cli.StringFlag{
Name: "replication",
Value: "",
Usage: "Cassandra keyspace replication options",
},
cli.BoolFlag{
Name: "list-streams",
Usage: "List streams in Cassandra",
},
}
app.Action = func(c *cli.Context) error {
config := Config{}
config.Features = make(map[string]bool)
config.Keyspace = c.String("keyspace")
config.Hosts = strings.Split(c.String("hosts"), ",")
config.StatsdAddr = c.String("telemetry")
config.ReplicationOpts = c.String("replication")
if c.Bool("migrate") {
config.Append(actions.Migrate{})
}
config.Append(actions.StartWorker{})
if c.Bool("list-streams") {
config.Append(actions.ListStreams{})
}
if c.Bool("dev-logger") {
config.Features["dev_logger"] = true
}
config.Append(actions.HttpServer{
Port: c.Int("port"),
Addr: c.String("listen")})
config.PrettyPrint()
return config.Run()
}
app.Run(os.Args)
}