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

Side by Side Diff: appengine/cmd/dm/distributor/impl/jobsim/job.go

Issue 1537883002: Initial distributor implementation (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: work in progress Created 4 years, 11 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package jobsim
6
7 import (
8 "encoding/json"
9 "fmt"
10
11 "github.com/luci/luci-go/appengine/cmd/dm/distributor"
12 "github.com/luci/luci-go/appengine/cmd/dm/distributor/impl/jobsim/parser "
13 "github.com/luci/luci-go/appengine/cmd/dm/distributor/protos/jobsim"
14 "github.com/luci/luci-go/appengine/cmd/dm/enums/execution"
15 )
16
17 type Job struct {
18 GroupSeed int64
19 Uniq int64
20 Phrase parser.Phrase
21 PreviousState distributor.PersistentState
22
23 // execution information
24 State execution.State
25 PersistentState distributor.PersistentState
26 }
27
28 type questData struct {
29 GroupSeed int64 `json:",string"`
30 Uniq int64 `json:",string"`
31 Phrase string
32 }
33
34 func MakeJob(cfg *jobsim.Config, t distributor.TaskDescription) (*Job, error) {
35 q := &questData{}
36
37 err := json.Unmarshal(t.Payload(), q)
38 if err != nil {
39 return nil, err
40 }
41
42 if q.GroupSeed == 0 || q.Phrase == "" {
43 return nil, fmt.Errorf("incomplete job payload")
44 }
45
46 ret := &Job{
47 GroupSeed: q.GroupSeed,
48 Uniq: q.Uniq,
49 State: execution.Scheduled,
50 PreviousState: t.PreviousState(),
51 }
52 ret.Phrase, err = parser.ParsePhrase(q.Phrase)
53 return ret, err
54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698