shad-go/distbuild/pkg/worker/state.go
Fedor Korotkiy 6295c3f1a4 WIP
2020-03-27 22:56:55 +03:00

28 lines
501 B
Go

package worker
import (
"go.uber.org/zap"
"gitlab.com/slon/shad-go/distbuild/pkg/proto"
)
func (w *Worker) buildHeartbeat() *proto.HeartbeatRequest {
w.mu.Lock()
defer w.mu.Unlock()
req := &proto.HeartbeatRequest{
FinishedJob: w.finishedJobs,
}
w.finishedJobs = nil
return req
}
func (w *Worker) jobFinished(job *proto.JobResult) {
w.log.Debug("job finished", zap.String("job_id", job.ID.String()))
w.mu.Lock()
defer w.mu.Unlock()
w.finishedJobs = append(w.finishedJobs, *job)
}