Skip to content

Commit

Permalink
DB: add studyjob table and extend worker table
Browse files Browse the repository at this point in the history
Signed-off-by: YujiOshima <[email protected]>
  • Loading branch information
YujiOshima committed Feb 13, 2019
1 parent d6ea2d5 commit f8e5fa0
Show file tree
Hide file tree
Showing 19 changed files with 3,299 additions and 868 deletions.
32 changes: 31 additions & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,36 @@ func (s *server) GetStudyList(ctx context.Context, in *api_pb.GetStudyListReques
return &api_pb.GetStudyListReply{StudyOverviews: result}, err
}

func (s *server) RegisterStudyJob(ctx context.Context, in *api_pb.RegisterStudyJobRequest) (*api_pb.RegisterStudyJobReply, error) {
err := dbIf.RegisterStudyJob(in.StudyJob)
return &api_pb.RegisterStudyJobReply{
StudyJobUid: in.StudyJob.StudyJobUid,
}, err
}

func (s *server) GetStudyJob(ctx context.Context, in *api_pb.GetStudyJobRequest) (*api_pb.GetStudyJobReply, error) {
sj, err := dbIf.GetStudyJob(in.StudyJobUid)
return &api_pb.GetStudyJobReply{
StudyJob: sj,
}, err
}

func (s *server) GetStudyJobList(ctx context.Context, in *api_pb.GetStudyJobListRequest) (*api_pb.GetStudyJobListReply, error) {
sjIds, err := dbIf.GetStudyJobList(in.StudyId)
return &api_pb.GetStudyJobListReply{
StudyJobUids: sjIds,
}, err
}
func (s *server) DeleteStudyJob(ctx context.Context, in *api_pb.DeleteStudyJobRequest) (*api_pb.DeleteStudyJobReply, error) {
if in == nil || in.StudyJobUid == "" {
return &api_pb.DeleteStudyJobReply{}, errors.New("StudyJobUID is missing.")
}
err := dbIf.DeleteStudyJob(in.StudyJobUid)
if err != nil {
return &api_pb.DeleteStudyJobReply{}, err
}
return &api_pb.DeleteStudyJobReply{StudyJobUid: in.StudyJobUid}, nil
}
func (s *server) CreateTrial(ctx context.Context, in *api_pb.CreateTrialRequest) (*api_pb.CreateTrialReply, error) {
err := dbIf.CreateTrial(in.Trial)
return &api_pb.CreateTrialReply{TrialId: in.Trial.TrialId}, err
Expand Down Expand Up @@ -207,7 +237,7 @@ func (s *server) ReportMetricsLogs(ctx context.Context, in *api_pb.ReportMetrics
}

func (s *server) UpdateWorkerState(ctx context.Context, in *api_pb.UpdateWorkerStateRequest) (*api_pb.UpdateWorkerStateReply, error) {
err := dbIf.UpdateWorker(in.WorkerId, in.Status)
err := dbIf.UpdateWorker(in.WorkerId, in.NewStatus)
return &api_pb.UpdateWorkerStateReply{}, err
}

Expand Down
Loading

0 comments on commit f8e5fa0

Please sign in to comment.