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

Side by Side Diff: scheduler/appengine/apiservers/scheduler.go

Issue 2945843002: scheduler WIP: add GetAllJobs api. (Closed)
Patch Set: review 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package apiservers 5 package apiservers
6 6
7 import ( 7 import (
8 "github.com/luci/luci-go/scheduler/api/scheduler/v1" 8 "github.com/luci/luci-go/scheduler/api/scheduler/v1"
9 "github.com/luci/luci-go/scheduler/appengine/catalog" 9 "github.com/luci/luci-go/scheduler/appengine/catalog"
10 "github.com/luci/luci-go/scheduler/appengine/engine" 10 "github.com/luci/luci-go/scheduler/appengine/engine"
11 "golang.org/x/net/context"
12 "google.golang.org/grpc"
13 "google.golang.org/grpc/codes"
11 ) 14 )
12 15
13 // SchedulerServer implements scheduler.Scheduler API. 16 // SchedulerServer implements scheduler.Scheduler API.
14 type SchedulerServer struct { 17 type SchedulerServer struct {
15 Engine engine.Engine 18 Engine engine.Engine
16 Catalog catalog.Catalog 19 Catalog catalog.Catalog
17 } 20 }
18 21
19 var _ scheduler.SchedulerServer = (*SchedulerServer)(nil) 22 var _ scheduler.SchedulerServer = (*SchedulerServer)(nil)
23
24 // GetJobs fetches all jobs satisfying JobsRequest and visibility ACLs.
25 func (s SchedulerServer) GetJobs(ctx context.Context, in *scheduler.JobsRequest) (*scheduler.JobsReply, error) {
26 var ejobs []*engine.Job
27 var err error
28 if in.GetProject() == "" {
29 ejobs, err = s.Engine.GetAllJobs(ctx)
30 } else {
31 ejobs, err = s.Engine.GetProjectJobs(ctx, in.GetProject())
32 }
33 if err != nil {
34 return nil, grpc.Errorf(codes.Internal, "datastore error: %s", e rr)
35 }
36
37 jobs := make([]*scheduler.Job, len(ejobs))
38 for i, ej := range ejobs {
39 jobs[i] = &scheduler.Job{
40 Id: ej.JobID,
41 Project: ej.ProjectID,
42 Schedule: ej.Schedule,
43 State: &scheduler.JobState{
44 UiStatus: string(ej.State.State),
tandrii(chromium) 2017/06/20 13:41:02 hold on, I didn't actually make this use UI-friend
45 },
46 }
47 }
48 return &scheduler.JobsReply{Jobs: jobs}, nil
49 }
OLDNEW
« 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