shad-go/distbuild/pkg/worker/state.go

24 lines
420 B
Go
Raw Normal View History

2020-03-14 10:24:44 +00:00
package worker
2020-03-29 16:03:07 +00:00
import "gitlab.com/slon/shad-go/distbuild/pkg/api"
2020-03-14 10:24:44 +00:00
2020-03-29 16:03:07 +00:00
func (w *Worker) buildHeartbeat() *api.HeartbeatRequest {
2020-03-14 10:24:44 +00:00
w.mu.Lock()
defer w.mu.Unlock()
2020-03-29 16:03:07 +00:00
req := &api.HeartbeatRequest{
2020-03-28 21:34:09 +00:00
WorkerID: w.id,
2020-03-14 10:24:44 +00:00
FinishedJob: w.finishedJobs,
}
w.finishedJobs = nil
return req
}
2020-03-29 16:03:07 +00:00
func (w *Worker) jobFinished(job *api.JobResult) {
2020-03-14 10:24:44 +00:00
w.mu.Lock()
defer w.mu.Unlock()
w.finishedJobs = append(w.finishedJobs, *job)
}