shad-go/distbuild/pkg/worker/state.go
2020-03-29 19:03:07 +03:00

23 lines
420 B
Go

package worker
import "gitlab.com/slon/shad-go/distbuild/pkg/api"
func (w *Worker) buildHeartbeat() *api.HeartbeatRequest {
w.mu.Lock()
defer w.mu.Unlock()
req := &api.HeartbeatRequest{
WorkerID: w.id,
FinishedJob: w.finishedJobs,
}
w.finishedJobs = nil
return req
}
func (w *Worker) jobFinished(job *api.JobResult) {
w.mu.Lock()
defer w.mu.Unlock()
w.finishedJobs = append(w.finishedJobs, *job)
}