/
builderapi.go
35 lines (28 loc) · 965 Bytes
/
builderapi.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"fmt"
"golang.org/x/net/context"
pb "github.com/brotherlogic/builder/proto"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
const (
// QUEUE - Where we store incoming requests
QUEUE = "/github.com/brotherlogic/recordadder/queue"
)
var (
btime = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "builder_last_build_time",
Help: "The size of the print queue",
}, []string{"job"})
)
// AddRecord adds a record into the system
func (s *Server) Refresh(ctx context.Context, req *pb.RefreshRequest) (*pb.RefreshResponse, error) {
s.CtxLog(ctx, fmt.Sprintf("Building for %v", req.GetJob()))
err := s.runBuild(ctx, fmt.Sprintf("git@github.com:brotherlogic/%v", req.GetJob()))
s.CtxLog(ctx, fmt.Sprintf("Build result: %v", err))
if err != nil {
s.BounceIssue(ctx, "Refresh Build Error", fmt.Sprintf("%v", err), req.GetJob())
}
return &pb.RefreshResponse{}, err
}