Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1455)

Unified Diff: scheduler/appengine/apiservers/scheduler.go

Issue 2948163002: scheduler: add GetJobInvocations api. (Closed)
Patch Set: grpc.error Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scheduler/api/scheduler/v1/scheduler.pb.go ('k') | scheduler/appengine/apiservers/scheduler_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scheduler/appengine/apiservers/scheduler.go
diff --git a/scheduler/appengine/apiservers/scheduler.go b/scheduler/appengine/apiservers/scheduler.go
index 6cece118514558ea222f8dc80b621eb35cd63771..3de1d4e5aed5995af4b3f0770ecc83cce455d774 100644
--- a/scheduler/appengine/apiservers/scheduler.go
+++ b/scheduler/appengine/apiservers/scheduler.go
@@ -52,3 +52,41 @@ func (s SchedulerServer) GetJobs(ctx context.Context, in *scheduler.JobsRequest)
}
return &scheduler.JobsReply{Jobs: jobs}, nil
}
+
+func (s SchedulerServer) GetInvocations(ctx context.Context, in *scheduler.InvocationsRequest) (*scheduler.InvocationsReply, error) {
+ ejob, err := s.Engine.GetJob(ctx, in.GetProject()+"/"+in.GetJob())
+ if err != nil {
+ return nil, grpc.Errorf(codes.Internal, "datastore error: %s", err)
+ }
+ if ejob == nil {
+ return nil, grpc.Errorf(codes.NotFound, "Job does not exist or you have no access")
+ }
+
+ pageSize := 50
+ if in.PageSize > 0 && int(in.PageSize) < pageSize {
+ pageSize = int(in.PageSize)
+ }
+
+ einvs, cursor, err := s.Engine.ListInvocations(ctx, ejob.JobID, pageSize, in.GetCursor())
+ if err != nil {
+ return nil, grpc.Errorf(codes.Internal, "datastore error: %s", err)
+ }
+ invs := make([]*scheduler.Invocation, len(einvs))
+ for i, einv := range einvs {
+ invs[i] = &scheduler.Invocation{
+ Id: einv.ID,
+ Job: ejob.GetJobName(),
+ Project: ejob.ProjectID,
+ StartedTs: einv.Started.UnixNano() / 1000,
+ TriggeredBy: string(einv.TriggeredBy),
+ Status: string(einv.Status),
+ Final: einv.Status.Final(),
+ ConfigRevision: einv.Revision,
+ ViewUrl: einv.ViewURL,
+ }
+ if einv.Status.Final() {
+ invs[i].FinishedTs = einv.Finished.UnixNano() / 1000
+ }
+ }
+ return &scheduler.InvocationsReply{Invocations: invs, NextCursor: cursor}, nil
+}
« no previous file with comments | « scheduler/api/scheduler/v1/scheduler.pb.go ('k') | scheduler/appengine/apiservers/scheduler_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698