-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
31 lines (26 loc) · 894 Bytes
/
options.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
package main
import (
"flag"
)
type Options struct {
dataDir string // data directory
httpAddress string // http server address
raftTCPAddress string // construct Raft Address
bootstrap bool // start as master or not
joinAddress string // peer address to join
}
func NewOptions() *Options {
opts := &Options{}
var httpAddress = flag.String("http", "127.0.0.1:6000", "Http address")
var raftTCPAddress = flag.String("raft", "127.0.0.1:7000", "raft tcp address")
var node = flag.String("node", "node1", "raft node name")
var bootstrap = flag.Bool("bootstrap", false, "start as raft cluster")
var joinAddress = flag.String("join", "", "join address for raft cluster")
flag.Parse()
opts.dataDir = "./" + *node
opts.httpAddress = *httpAddress
opts.bootstrap = *bootstrap
opts.raftTCPAddress = *raftTCPAddress
opts.joinAddress = *joinAddress
return opts
}