// StartAll creates and starts a new listener for each application // registered in the store. func StartAll(s source.ConfigSource, queue Queue) error { appNames, err := s.ListAppNames() if err != nil { return err } if len(appNames) == 0 { log.Print("No applications found. Exiting.") return nil } errc := make(chan int, len(appNames)) qc := make(chan *Tweet, len(appNames)*100) queue.Start(qc) allListeners := make([]Listener, 0, len(appNames)) for _, name := range appNames { storedApp, getErr := s.GetApp(name) if getErr != nil { log.Printf("ERROR fetching app %q: %v", name, getErr) continue } userIDs, userErr := s.ListTwitterIDs(name) if userErr != nil { return userErr } listener := NewListener(storedApp, userIDs, qc, errc) allListeners = append(allListeners, listener) go listener.Start() } aw := NewAppWatcher(APP_TOPIC, allListeners, s) return aw.Watch(qc, errc) }