Ejemplo n.º 1
0
func discovering(wg *sync.WaitGroup) {
	defer wg.Done()
	c := make(chan tutum.Event)
	e := make(chan error)

	nodes.DiscoverPeers()

	go tutum.TutumEvents(c, e)
Loop:
	for {
		select {
		case event := <-c:
			if event.Type == "node" && (event.State == "Deployed" || event.State == "Terminated") {
				err := nodes.DiscoverPeers()
				if err != nil {
					log.Println(err)
				}
			}
			break
		case err := <-e:
			log.Println("[NODE DISCOVERY ERROR]: " + err.Error())
			time.Sleep(5 * time.Second)
			wg.Add(1)
			go discovering(wg)
			break Loop
		}
	}
}
Ejemplo n.º 2
0
func nodeEventHandler(eventType string, state string) error {
	if eventType == "node" && (state == "Deployed" || state == "Terminated") {
		err := nodes.DiscoverPeers()
		if err != nil {
			return err
		}
	}
	return nil
}
Ejemplo n.º 3
0
func discovering(wg *sync.WaitGroup) {
	defer wg.Done()
	c := make(chan tutum.Event)
	e := make(chan error)

	nodes.DiscoverPeers()

	go tutum.TutumEvents(c, e)
	tutumEventHandler(wg, c, e)
}