-
Notifications
You must be signed in to change notification settings - Fork 132
/
lookout.go
44 lines (36 loc) · 1.44 KB
/
lookout.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
36
37
38
39
40
41
42
43
44
package server
import (
"context"
"github.com/gogo/protobuf/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/armadaproject/armada/internal/lookout/repository"
"github.com/armadaproject/armada/pkg/api/lookout"
)
type LookoutServer struct {
jobRepository repository.JobRepository
}
func NewLookoutServer(jobRepository repository.JobRepository) *LookoutServer {
return &LookoutServer{jobRepository: jobRepository}
}
func (s *LookoutServer) Overview(ctx context.Context, _ *types.Empty) (*lookout.SystemOverview, error) {
queues, err := s.jobRepository.GetQueueInfos(ctx)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to query queue stats: %s", err)
}
return &lookout.SystemOverview{Queues: queues}, nil
}
func (s *LookoutServer) GetJobSets(ctx context.Context, opts *lookout.GetJobSetsRequest) (*lookout.GetJobSetsResponse, error) {
jobSets, err := s.jobRepository.GetJobSetInfos(ctx, opts)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to query queue stats: %s", err)
}
return &lookout.GetJobSetsResponse{JobSetInfos: jobSets}, nil
}
func (s *LookoutServer) GetJobs(ctx context.Context, opts *lookout.GetJobsRequest) (*lookout.GetJobsResponse, error) {
jobInfos, err := s.jobRepository.GetJobs(ctx, opts)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to query jobs in queue: %s", err)
}
return &lookout.GetJobsResponse{JobInfos: jobInfos}, nil
}