You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.
Robert Catmull edited this page Dec 15, 2020
·
4 revisions
If your workers needs to stop at a deadline or you just need to have a timeout use the SetTimeout or SetDeadline methods.
Worker functions backbone is errgroups, because of this when you look for the signal (IsDone() as seen below), you need to return an error
and handle it otherwise the errgroup will wait for your worker functions to be finish causing deadlock.
// Setting a timeout of 2 secondstimeoutWorker.SetTimeout(2*time.Second)
// Setting a deadline of 4 hours from nowdeadlineWorker.SetDeadline(time.Now().Add(4*time.Hour))
func (my*MyWorker) Work(w*worker.Worker, ininterface{}) error {
fmt.Println(in)
time.Sleep(1*time.Second)
}