OLD | NEW |
1 // Copyright 2015 The LUCI Authors. | 1 // Copyright 2015 The LUCI Authors. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // ErrNoOwnerPermission (assuming caller has READER access, else see above). | 71 // ErrNoOwnerPermission (assuming caller has READER access, else see above). |
72 type Engine interface { | 72 type Engine interface { |
73 // GetVisibleJobs returns a list of all enabled scheduler jobs in no | 73 // GetVisibleJobs returns a list of all enabled scheduler jobs in no |
74 // particular order. | 74 // particular order. |
75 GetVisibleJobs(c context.Context) ([]*Job, error) | 75 GetVisibleJobs(c context.Context) ([]*Job, error) |
76 | 76 |
77 // GetVisibleProjectJobs returns a list of enabled scheduler jobs of som
e | 77 // GetVisibleProjectJobs returns a list of enabled scheduler jobs of som
e |
78 // project in no particular order. | 78 // project in no particular order. |
79 GetVisibleProjectJobs(c context.Context, projectID string) ([]*Job, erro
r) | 79 GetVisibleProjectJobs(c context.Context, projectID string) ([]*Job, erro
r) |
80 | 80 |
81 » // GetVisibleJob returns single scheduler job given its full ID or nil i
f no such | 81 » // GetVisibleJob returns single scheduler job given its full ID. |
82 » // job or if not visible. | 82 » // ErrNoSuchJob error is returned if job doesn't exist OR isn't visible. |
83 GetVisibleJob(c context.Context, jobID string) (*Job, error) | 83 GetVisibleJob(c context.Context, jobID string) (*Job, error) |
84 | 84 |
85 // ListVisibleInvocations returns invocations of a visible job, most rec
ent first. | 85 // ListVisibleInvocations returns invocations of a visible job, most rec
ent first. |
86 // Returns fetched invocations and cursor string if there's more. | 86 // Returns fetched invocations and cursor string if there's more. |
| 87 // error is ErrNoSuchJob if job doesn't exist or isn't visible. |
87 ListVisibleInvocations(c context.Context, jobID string, pageSize int, cu
rsor string) ([]*Invocation, string, error) | 88 ListVisibleInvocations(c context.Context, jobID string, pageSize int, cu
rsor string) ([]*Invocation, string, error) |
88 | 89 |
89 // GetVisibleInvocation returns single invocation of some job given its
ID. | 90 // GetVisibleInvocation returns single invocation of some job given its
ID. |
| 91 // ErrNoSuchInvocation is returned if either job or invocation doesn't e
xist |
| 92 // or job and hence invocation isn't visible. |
90 GetVisibleInvocation(c context.Context, jobID string, invID int64) (*Inv
ocation, error) | 93 GetVisibleInvocation(c context.Context, jobID string, invID int64) (*Inv
ocation, error) |
91 | 94 |
92 // GetVisibleInvocationsByNonce returns a list of Invocations with given
nonce. | 95 // GetVisibleInvocationsByNonce returns a list of Invocations with given
nonce. |
93 // | 96 // |
94 // Invocation nonce is a random number that identifies an intent to star
t | 97 // Invocation nonce is a random number that identifies an intent to star
t |
95 // an invocation. Normally one nonce corresponds to one Invocation entit
y, | 98 // an invocation. Normally one nonce corresponds to one Invocation entit
y, |
96 // but there can be more if job fails to start with a transient error. | 99 // but there can be more if job fails to start with a transient error. |
97 GetVisibleInvocationsByNonce(c context.Context, invNonce int64) ([]*Invo
cation, error) | 100 GetVisibleInvocationsByNonce(c context.Context, invNonce int64) ([]*Invo
cation, error) |
98 | 101 |
99 // PauseJob replaces job's schedule with "triggered", effectively preven
ting | 102 // PauseJob replaces job's schedule with "triggered", effectively preven
ting |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 default: | 724 default: |
722 return nil, transient.Tag.Apply(err) | 725 return nil, transient.Tag.Apply(err) |
723 } | 726 } |
724 } | 727 } |
725 | 728 |
726 func (e *engineImpl) PublicAPI() Engine { | 729 func (e *engineImpl) PublicAPI() Engine { |
727 return e | 730 return e |
728 } | 731 } |
729 | 732 |
730 func (e *engineImpl) ListVisibleInvocations(c context.Context, jobID string, pag
eSize int, cursor string) ([]*Invocation, string, error) { | 733 func (e *engineImpl) ListVisibleInvocations(c context.Context, jobID string, pag
eSize int, cursor string) ([]*Invocation, string, error) { |
731 » if job, err := e.GetVisibleJob(c, jobID); err != nil { | 734 » if _, err := e.GetVisibleJob(c, jobID); err != nil { |
732 return nil, "", err | 735 return nil, "", err |
733 } else if job == nil { | |
734 // Either no Job or no access, both imply returning no invocatio
ns. | |
735 return nil, "", ErrNoSuchInvocation | |
736 } | 736 } |
737 | 737 |
738 if pageSize == 0 || pageSize > 500 { | 738 if pageSize == 0 || pageSize > 500 { |
739 pageSize = 500 | 739 pageSize = 500 |
740 } | 740 } |
741 | 741 |
742 // Deserialize the cursor. | 742 // Deserialize the cursor. |
743 var cursorObj ds.Cursor | 743 var cursorObj ds.Cursor |
744 if cursor != "" { | 744 if cursor != "" { |
745 var err error | 745 var err error |
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2072 } | 2072 } |
2073 if hasFinished { | 2073 if hasFinished { |
2074 return ctl.eng.rollSM(c, job, func(sm *StateMachine) err
or { | 2074 return ctl.eng.rollSM(c, job, func(sm *StateMachine) err
or { |
2075 sm.OnInvocationDone(saving.ID) | 2075 sm.OnInvocationDone(saving.ID) |
2076 return nil | 2076 return nil |
2077 }) | 2077 }) |
2078 } | 2078 } |
2079 return nil | 2079 return nil |
2080 }) | 2080 }) |
2081 } | 2081 } |
OLD | NEW |