Exemple #1
0
func (l *ExampleListener) OnJoin(zk *zkutil.ZooKeeper) {
	log.Println("Joining!")
	// Create an assigned task for this node as soon as it joins...
	data := make(map[string]interface{})
	// assign this task specifically to this node
	// data["example"] = l.config.NodeId
	donut.CreateTask("example", zk.Conn, "task-"+l.config.NodeId, data)
	go func() {
		// only do this task for 5 seconds
		time.Sleep(60 * time.Second)
		donut.CompleteTask("example", zk.Conn, "task-"+l.config.NodeId)
	}()
}
Exemple #2
0
func (c *Ctl) removeTask(cluster, taskId string) error {
	donut.CompleteTask(cluster, c.zk, taskId)
	return nil
}