修复
This commit is contained in:
parent
4195de3818
commit
f9c68c748c
|
@ -14,6 +14,7 @@ type ConfigServer struct {
|
|||
ServerID uint64 `yaml:"serverid"`
|
||||
Host string `yaml:"host"`
|
||||
Port int `yaml:"port"`
|
||||
Cluster []string `yaml:"cluster"`
|
||||
}
|
||||
|
||||
func (cfg *ConfigServer) Address() string {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
serverid: 1
|
||||
host: "localhost"
|
||||
port: 5050
|
||||
cluster: [ "localhost:5050","localhost:5051","localhost:5052" ]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
serverid: 2
|
||||
host: "localhost"
|
||||
port: 5051
|
||||
cluster: [ "localhost:5050","localhost:5051","localhost:5052" ]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
serverid: 3
|
||||
host: "localhost"
|
||||
port: 5052
|
||||
cluster: [ "localhost:5050","localhost:5051","localhost:5052" ]
|
||||
|
|
10
main.go
10
main.go
|
@ -41,12 +41,6 @@ var DequeueHandler = triggered.RegisterExecute(func(params *triggered.Params[boo
|
|||
|
||||
})
|
||||
|
||||
var addresses []string = []string{
|
||||
"localhost:5500",
|
||||
"localhost:5501",
|
||||
"localhost:5502",
|
||||
}
|
||||
|
||||
func StartNode(cfg *ConfigServer) {
|
||||
|
||||
replicaID := cfg.ServerID
|
||||
|
@ -72,7 +66,7 @@ func StartNode(cfg *ConfigServer) {
|
|||
// leave the initialMembers to be empty. we still populate the initialMembers
|
||||
// here for simplicity.
|
||||
|
||||
for idx, v := range addresses {
|
||||
for idx, v := range cfg.Cluster {
|
||||
// key is the ReplicaID, ReplicaID is not allowed to be 0
|
||||
// value is the raft address
|
||||
initialMembers[uint64(idx+1)] = v
|
||||
|
@ -140,7 +134,7 @@ func StartNode(cfg *ConfigServer) {
|
|||
// 设置共享的参数
|
||||
DequeueHandler.WithShared(nh)
|
||||
|
||||
if err := nh.StartReplica(initialMembers, false, NewSMQueue, rc); err != nil {
|
||||
if err := nh.StartReplica(initialMembers, true, NewSMQueue, rc); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to add cluster, %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user