func processResults(dbMan db.DatabaseManager) { for { log.Println("waiting for job") job := WorkerPool.WaitForJob() if job == nil { backoff += 5 // add 5 seconds every time there are no jobs to process time.Sleep(backoff * time.Second) continue } else { backoff = 5 // reset backoff log.Println("got job") } if job.Result == nil { log.Println("job result in nil:", job.Err) } else { result := job.Result.(feedFetchResult) if result.err != nil { log.Println("got error: ", result.err) } else { if job.Args[0].(string) == "kill" { break } url := job.Args[0].(string) // send out notifications ids := dbMan.GetSubscribers(url) for _, id := range ids { log.Print("send notification to: ", id, result.feed) } log.Printf("found: %s %q\n", url, result.feed) } } } }