| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 engine implements the core logic of the scheduler service. | 5 // Package engine implements the core logic of the scheduler service. |
| 6 package engine | 6 package engine |
| 7 | 7 |
| 8 import ( | 8 import ( |
| 9 "bytes" | 9 "bytes" |
| 10 "encoding/json" | 10 "encoding/json" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 Schedule string `gae:",noindex"` | 250 Schedule string `gae:",noindex"` |
| 251 | 251 |
| 252 // Task is the job's payload in serialized form. Opaque from the point o
f view | 252 // Task is the job's payload in serialized form. Opaque from the point o
f view |
| 253 // of the engine. See Catalog.UnmarshalTask(). | 253 // of the engine. See Catalog.UnmarshalTask(). |
| 254 Task []byte `gae:",noindex"` | 254 Task []byte `gae:",noindex"` |
| 255 | 255 |
| 256 // State is the job's state machine state, see StateMachine. | 256 // State is the job's state machine state, see StateMachine. |
| 257 State JobState | 257 State JobState |
| 258 } | 258 } |
| 259 | 259 |
| 260 // GetJobName returns name of this Job as defined its project's config. |
| 261 func (e *Job) GetJobName() string { |
| 262 // JobID has form <project>/<id>. Split it into components. |
| 263 chunks := strings.Split(e.JobID, "/") |
| 264 return chunks[1] |
| 265 } |
| 266 |
| 260 // effectiveSchedule returns schedule string to use for the job, considering its | 267 // effectiveSchedule returns schedule string to use for the job, considering its |
| 261 // Paused field. | 268 // Paused field. |
| 262 // | 269 // |
| 263 // Paused jobs always use "triggered" schedule. | 270 // Paused jobs always use "triggered" schedule. |
| 264 func (e *Job) effectiveSchedule() string { | 271 func (e *Job) effectiveSchedule() string { |
| 265 if e.Paused { | 272 if e.Paused { |
| 266 return "triggered" | 273 return "triggered" |
| 267 } | 274 } |
| 268 return e.Schedule | 275 return e.Schedule |
| 269 } | 276 } |
| (...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1930 } | 1937 } |
| 1931 if hasFinished { | 1938 if hasFinished { |
| 1932 return ctl.eng.rollSM(c, job, func(sm *StateMachine) err
or { | 1939 return ctl.eng.rollSM(c, job, func(sm *StateMachine) err
or { |
| 1933 sm.OnInvocationDone(saving.ID) | 1940 sm.OnInvocationDone(saving.ID) |
| 1934 return nil | 1941 return nil |
| 1935 }) | 1942 }) |
| 1936 } | 1943 } |
| 1937 return nil | 1944 return nil |
| 1938 }) | 1945 }) |
| 1939 } | 1946 } |
| OLD | NEW |