func (e *EtcdProxy) WatchJobOffers(notify chan *scheduler.Job, stopC chan bool) { watchC := make(chan *etcd.Response, 10) go e.etcdClient.Watch(JOB_OFFER_KEY, 0, true, watchC, stopC) for change := range watchC { // Notification received job, _ := scheduler.DecodeFromString(change.Node.Value) notify <- job } log.Print("watchC has been closed") }
func (e *EtcdProxy) WatchJobsToSchedule(notify chan *scheduler.Job, stopC chan bool) error { watchC := make(chan *etcd.Response, 50) go e.etcdClient.Watch(JOB_REGISTRATION_KEY, 0, true, watchC, stopC) for change := range watchC { //log.Printf("[etcd] new job found: %+v \n", change.Node.Value) job, _ := scheduler.DecodeFromString(change.Node.Value) notify <- job } return nil }