28 lines
553 B
Plaintext
28 lines
553 B
Plaintext
package zooKeeperMgr
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// ZooKeeper配置对象
|
|
type ZooKeeperConfig struct {
|
|
// ZooKeeper的服务器地址(如果有多个地址,则用,分隔)
|
|
Servers string
|
|
|
|
// 起始节点路径
|
|
StartPath string
|
|
|
|
// 会话超时时间(单位:秒)
|
|
SessionTimeout time.Duration
|
|
}
|
|
|
|
// 获取所有的ZooKeeper服务器列表
|
|
func (this *ZooKeeperConfig) GetServerList() []string {
|
|
return strings.Split(this.Servers, ",")
|
|
}
|
|
|
|
func (this *ZooKeeperConfig) Parse() {
|
|
this.SessionTimeout = this.SessionTimeout * time.Second
|
|
}
|