func (w *startCollector) Work() { if !w.isReady() { return } name, err := w.getLoginName() if err != nil { w.prepareNext() workers.Log(w, err) return } last := w.getLast() for r := range w.watchEvents(name, last) { text := fmt.Sprintf( "%s starred: %s", *r.Event.Actor.Login, "https://github.com/"+*r.Event.Repo.Name, ) w.notifier.Notify(text) if last.Unix()-(*r.Event.CreatedAt).Unix() < 0 { last = *r.Event.CreatedAt } } w.last = last w.prepareNext() }
func (w *workerImpl) Work() { channel, err := w.findChannel(w.channelName) if err != nil { workers.Log(w, err) return } message := slack.NewPostMessageParameters() message.Text = "test" message.Username = w.name w.client.PostMessage(channel.Id, message.Text, message) if err != nil { workers.Log(w, err) return } }
func run(worker workers.Worker, job *scheduler.Job) { if _, err := job.Run(worker.Work); err != nil { workers.Log(worker, err) return } }