Skip to content

Commit

Permalink
Refactor exmaple config
Browse files Browse the repository at this point in the history
  • Loading branch information
kevburnsjr committed Mar 2, 2024
1 parent b968f5c commit db47ee6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
14 changes: 7 additions & 7 deletions _example/kv1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ clean-data:
@rm -rf $(DATA_DIR)/node*
@rm -rf $(DATA_DIR)/raft*

PEERS := 127.0.0.1:17011,127.0.0.1:17021,127.0.0.1:17031
PEERS := 127.0.0.1:17013,127.0.0.1:17023,127.0.0.1:17033

test-node-1:
@go run *.go -d $(DATA_DIR)/node1 -a 127.0.0.1:17011 -r 127.0.0.1:17012 -g 127.0.0.1:17013 -h :8001 -p $(PEERS) -z us-west-1a
@go run *.go -d $(DATA_DIR)/node1 -g 127.0.0.1:17011 -r 127.0.0.1:17012 -a 127.0.0.1:17013 -h :8001 -p $(PEERS) -z us-west-1a

test-node-2:
@go run *.go -d $(DATA_DIR)/node2 -a 127.0.0.1:17021 -r 127.0.0.1:17022 -g 127.0.0.1:17023 -h :8002 -p $(PEERS) -z us-west-1c
@go run *.go -d $(DATA_DIR)/node2 -g 127.0.0.1:17021 -r 127.0.0.1:17022 -a 127.0.0.1:17023 -h :8002 -p $(PEERS) -z us-west-1c

test-node-3:
@go run *.go -d $(DATA_DIR)/node3 -a 127.0.0.1:17031 -r 127.0.0.1:17032 -g 127.0.0.1:17033 -h :8003 -p $(PEERS) -z us-west-1f
@go run *.go -d $(DATA_DIR)/node3 -g 127.0.0.1:17031 -r 127.0.0.1:17032 -a 127.0.0.1:17033 -h :8003 -p $(PEERS) -z us-west-1f

test-node-4:
@go run *.go -d $(DATA_DIR)/node4 -a 127.0.0.1:17041 -r 127.0.0.1:17042 -g 127.0.0.1:17043 -h :8004 -p $(PEERS) -z us-west-1a
@go run *.go -d $(DATA_DIR)/node4 -g 127.0.0.1:17041 -r 127.0.0.1:17042 -a 127.0.0.1:17043 -h :8004 -p $(PEERS) -z us-west-1a

test-node-5:
@go run *.go -d $(DATA_DIR)/node5 -a 127.0.0.1:17051 -r 127.0.0.1:17052 -g 127.0.0.1:17053 -h :8005 -p $(PEERS) -z us-west-1c
@go run *.go -d $(DATA_DIR)/node5 -g 127.0.0.1:17051 -r 127.0.0.1:17052 -a 127.0.0.1:17053 -h :8005 -p $(PEERS) -z us-west-1c

test-node-6:
@go run *.go -d $(DATA_DIR)/node6 -a 127.0.0.1:17061 -r 127.0.0.1:17062 -g 127.0.0.1:17063 -h :8006 -p $(PEERS) -z us-west-1f
@go run *.go -d $(DATA_DIR)/node6 -g 127.0.0.1:17061 -r 127.0.0.1:17062 -a 127.0.0.1:17063 -h :8006 -p $(PEERS) -z us-west-1f
31 changes: 16 additions & 15 deletions _example/kv1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ import (
)

var (
name = flag.String("n", `kv1`, "Cluster name (base36 maxlen 12)")
peers = flag.String("p", `kv1-usc1-a-0,kv1-usc1-c-0,kv1-usc1-f-0`, "Peer nodes")
region = flag.String("re", `us-central1`, "Region")
zone = flag.String("z", `us-central1-a`, "Zone")
shards = flag.Int("s", 4, "Shard count")
apiAddr = flag.String("a", "10.0.0.1:17001", "Internal gRPC api address")
gossipAddr = flag.String("g", "10.0.0.1:17001", "Memberlist gossip address")
raftAddr = flag.String("r", "10.0.0.1:17002", "Dragonboat raft address")
gossipAddr = flag.String("g", "10.0.0.1:17003", "Memberlist gossip address")
zongziAddr = flag.String("a", "10.0.0.1:17003", "Zongzi gRPC api address")
httpAddr = flag.String("h", "10.0.0.1:8000", "HTTP address")
dataDir = flag.String("d", "/var/lib/zongzi", "Base data directory")

name = flag.String("n", `kv1`, "Cluster name (base36 maxlen 12)")
peers = flag.String("p", `kv1-usc1-a-0,kv1-usc1-c-0,kv1-usc1-f-0`, "Peer nodes")
region = flag.String("re", `us-central1`, "Region")
zone = flag.String("z", `us-central1-a`, "Zone")
dataDir = flag.String("d", "/var/lib/zongzi", "Base data directory")
shards = flag.Int("s", 4, "Shard count")
)

func main() {
Expand All @@ -33,19 +34,19 @@ func main() {
ctx := context.Background()
ctrl := newController()
agent, err := zongzi.NewAgent(*name, strings.Split(*peers, ","),
zongzi.WithHostTags(
fmt.Sprintf(`geo:region=%s`, *region),
fmt.Sprintf(`geo:zone=%s`, *zone)),
zongzi.WithApiAddress(*apiAddr),
zongzi.WithGossipAddress(*gossipAddr),
zongzi.WithHostConfig(zongzi.HostConfig{
NodeHostDir: *dataDir + "/raft",
NotifyCommit: true,
RaftAddress: *raftAddr,
RTTMillisecond: 2,
WALDir: *dataDir + "/wal",
}),
zongzi.WithRaftEventListener(ctrl))
zongzi.WithGossipAddress(*gossipAddr),
zongzi.WithRaftAddress(*raftAddr),
zongzi.WithApiAddress(*zongziAddr),
zongzi.WithRaftEventListener(ctrl),
zongzi.WithHostTags(
fmt.Sprintf(`geo:region=%s`, *region),
fmt.Sprintf(`geo:zone=%s`, *zone)))
if err != nil {
panic(err)
}
Expand Down

0 comments on commit db47ee6

Please sign in to comment.