Documentation ¶
Index ¶
Constants ¶
View Source
const ZKPathACK = "/ACK"
View Source
const ZkPathBc = "/BROADCAST"
View Source
const ZkPathCoordinateLock = "/COORDINATOR"
View Source
const ZkPathRc = "/REGISTER_CENTER"
View Source
const ZkPathVersion = "/PATH_INIT"
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { Id string // 标记一个节点 ZkPath ZkPath // 项目zookeeper 路径 Sharding Sharding // 定义的Sharding, Job 也由此传入 WaitAckTimeout time.Duration // 等待ack 超时时间, 默认5s // contains filtered or unexported fields }
Using Node, just create a Node struct, and call start method.
type Sharding ¶
type Sharding interface { Encode() []byte // 编码和解码,保存于zk broadcast中 Decode([]byte) Sharding // 需要函数返回 (用于前后diff 版本) Equal(sharding Sharding) bool // diff sharding 是否相同, 如果相同则不再reBalance Version() string // 版本, 若更新了shard内容,则需要更新版本 ReBalance([]string) Sharding // 重新分配任务 }
Sharding need convert to []byte, save at zookeeper response node.
type SimpleSharding ¶
一个简单的Sharding的实现,包含了版本信息和Sharding 的数据信息
func (*SimpleSharding) Decode ¶
func (sharding *SimpleSharding) Decode(data []byte) Sharding
func (*SimpleSharding) Encode ¶
func (sharding *SimpleSharding) Encode() []byte
func (*SimpleSharding) Equal ¶
func (sharding *SimpleSharding) Equal(sharding2 Sharding) bool
func (*SimpleSharding) ReBalance ¶
func (sharding *SimpleSharding) ReBalance(currentLiveNodes []string) Sharding
func (*SimpleSharding) Version ¶
func (sharding *SimpleSharding) Version() string
Click to show internal directories.
Click to hide internal directories.