修复
This commit is contained in:
parent
4195de3818
commit
f9c68c748c
|
@ -11,9 +11,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigServer struct {
|
type ConfigServer struct {
|
||||||
ServerID uint64 `yaml:"serverid"`
|
ServerID uint64 `yaml:"serverid"`
|
||||||
Host string `yaml:"host"`
|
Host string `yaml:"host"`
|
||||||
Port int `yaml:"port"`
|
Port int `yaml:"port"`
|
||||||
|
Cluster []string `yaml:"cluster"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cfg *ConfigServer) Address() string {
|
func (cfg *ConfigServer) Address() string {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
serverid: 1
|
serverid: 1
|
||||||
host: "localhost"
|
host: "localhost"
|
||||||
port: 5050
|
port: 5050
|
||||||
|
cluster: [ "localhost:5050","localhost:5051","localhost:5052" ]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
serverid: 2
|
serverid: 2
|
||||||
host: "localhost"
|
host: "localhost"
|
||||||
port: 5051
|
port: 5051
|
||||||
|
cluster: [ "localhost:5050","localhost:5051","localhost:5052" ]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
serverid: 3
|
serverid: 3
|
||||||
host: "localhost"
|
host: "localhost"
|
||||||
port: 5052
|
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) {
|
func StartNode(cfg *ConfigServer) {
|
||||||
|
|
||||||
replicaID := cfg.ServerID
|
replicaID := cfg.ServerID
|
||||||
|
@ -72,7 +66,7 @@ func StartNode(cfg *ConfigServer) {
|
||||||
// leave the initialMembers to be empty. we still populate the initialMembers
|
// leave the initialMembers to be empty. we still populate the initialMembers
|
||||||
// here for simplicity.
|
// 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
|
// key is the ReplicaID, ReplicaID is not allowed to be 0
|
||||||
// value is the raft address
|
// value is the raft address
|
||||||
initialMembers[uint64(idx+1)] = v
|
initialMembers[uint64(idx+1)] = v
|
||||||
|
@ -140,7 +134,7 @@ func StartNode(cfg *ConfigServer) {
|
||||||
// 设置共享的参数
|
// 设置共享的参数
|
||||||
DequeueHandler.WithShared(nh)
|
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)
|
fmt.Fprintf(os.Stderr, "failed to add cluster, %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user