xref: /aosp_15_r20/external/googleapis/google/cloud/scheduler/v1/job.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2022 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (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
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.cloud.scheduler.v1;
18
19import "google/api/resource.proto";
20import "google/cloud/scheduler/v1/target.proto";
21import "google/protobuf/duration.proto";
22import "google/protobuf/timestamp.proto";
23import "google/rpc/status.proto";
24
25option go_package = "cloud.google.com/go/scheduler/apiv1/schedulerpb;schedulerpb";
26option java_multiple_files = true;
27option java_outer_classname = "JobProto";
28option java_package = "com.google.cloud.scheduler.v1";
29
30// Configuration for a job.
31// The maximum allowed size for a job is 1MB.
32message Job {
33  option (google.api.resource) = {
34    type: "cloudscheduler.googleapis.com/Job"
35    pattern: "projects/{project}/locations/{location}/jobs/{job}"
36  };
37
38  // State of the job.
39  enum State {
40    // Unspecified state.
41    STATE_UNSPECIFIED = 0;
42
43    // The job is executing normally.
44    ENABLED = 1;
45
46    // The job is paused by the user. It will not execute. A user can
47    // intentionally pause the job using
48    // [PauseJobRequest][google.cloud.scheduler.v1.PauseJobRequest].
49    PAUSED = 2;
50
51    // The job is disabled by the system due to error. The user
52    // cannot directly set a job to be disabled.
53    DISABLED = 3;
54
55    // The job state resulting from a failed
56    // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]
57    // operation. To recover a job from this state, retry
58    // [CloudScheduler.UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob]
59    // until a successful response is received.
60    UPDATE_FAILED = 4;
61  }
62
63  // Optionally caller-specified in
64  // [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob], after
65  // which it becomes output only.
66  //
67  // The job name. For example:
68  // `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
69  //
70  // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
71  //    hyphens (-), colons (:), or periods (.).
72  //    For more information, see
73  //    [Identifying
74  //    projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
75  // * `LOCATION_ID` is the canonical ID for the job's location.
76  //    The list of available locations can be obtained by calling
77  //    [ListLocations][google.cloud.location.Locations.ListLocations].
78  //    For more information, see https://cloud.google.com/about/locations/.
79  // * `JOB_ID` can contain only letters ([A-Za-z]), numbers ([0-9]),
80  //    hyphens (-), or underscores (_). The maximum length is 500 characters.
81  string name = 1;
82
83  // Optionally caller-specified in
84  // [CreateJob][google.cloud.scheduler.v1.CloudScheduler.CreateJob] or
85  // [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob].
86  //
87  // A human-readable description for the job. This string must not contain
88  // more than 500 characters.
89  string description = 2;
90
91  // Required.
92  //
93  // Delivery settings containing destination and parameters.
94  oneof target {
95    // Pub/Sub target.
96    PubsubTarget pubsub_target = 4;
97
98    // App Engine HTTP target.
99    AppEngineHttpTarget app_engine_http_target = 5;
100
101    // HTTP target.
102    HttpTarget http_target = 6;
103  }
104
105  // Required, except when used with
106  // [UpdateJob][google.cloud.scheduler.v1.CloudScheduler.UpdateJob].
107  //
108  // Describes the schedule on which the job will be executed.
109  //
110  // The schedule can be either of the following types:
111  //
112  // * [Crontab](https://en.wikipedia.org/wiki/Cron#Overview)
113  // * English-like
114  // [schedule](https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules)
115  //
116  // As a general rule, execution `n + 1` of a job will not begin
117  // until execution `n` has finished. Cloud Scheduler will never
118  // allow two simultaneously outstanding executions. For example,
119  // this implies that if the `n+1`th execution is scheduled to run at
120  // 16:00 but the `n`th execution takes until 16:15, the `n+1`th
121  // execution will not start until `16:15`.
122  // A scheduled start time will be delayed if the previous
123  // execution has not ended when its scheduled time occurs.
124  //
125  // If [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] > 0 and
126  // a job attempt fails, the job will be tried a total of
127  // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] times,
128  // with exponential backoff, until the next scheduled start time.
129  string schedule = 20;
130
131  // Specifies the time zone to be used in interpreting
132  // [schedule][google.cloud.scheduler.v1.Job.schedule]. The value of this field
133  // must be a time zone name from the [tz
134  // database](http://en.wikipedia.org/wiki/Tz_database).
135  //
136  // Note that some time zones include a provision for
137  // daylight savings time. The rules for daylight saving time are
138  // determined by the chosen tz. For UTC use the string "utc". If a
139  // time zone is not specified, the default will be in UTC (also known
140  // as GMT).
141  string time_zone = 21;
142
143  // Output only. The creation time of the job.
144  google.protobuf.Timestamp user_update_time = 9;
145
146  // Output only. State of the job.
147  State state = 10;
148
149  // Output only. The response from the target for the last attempted execution.
150  google.rpc.Status status = 11;
151
152  // Output only. The next time the job is scheduled. Note that this may be a
153  // retry of a previously failed attempt or the next execution time
154  // according to the schedule.
155  google.protobuf.Timestamp schedule_time = 17;
156
157  // Output only. The time the last job attempt started.
158  google.protobuf.Timestamp last_attempt_time = 18;
159
160  // Settings that determine the retry behavior.
161  RetryConfig retry_config = 19;
162
163  // The deadline for job attempts. If the request handler does not respond by
164  // this deadline then the request is cancelled and the attempt is marked as a
165  // `DEADLINE_EXCEEDED` failure. The failed attempt can be viewed in
166  // execution logs. Cloud Scheduler will retry the job according
167  // to the [RetryConfig][google.cloud.scheduler.v1.RetryConfig].
168  //
169  // The default and the allowed values depend on the type of target:
170  //
171  // * For [HTTP targets][google.cloud.scheduler.v1.Job.http_target], the
172  // default is 3 minutes. The deadline must be in the interval [15 seconds, 30
173  // minutes].
174  //
175  // * For [App Engine HTTP
176  // targets][google.cloud.scheduler.v1.Job.app_engine_http_target], 0 indicates
177  // that the request has the default deadline. The default deadline depends on
178  // the scaling type of the service: 10 minutes for standard apps with
179  // automatic scaling, 24 hours for standard apps with manual and basic
180  // scaling, and 60 minutes for flex apps. If the request deadline is set, it
181  // must be in the interval [15 seconds, 24 hours 15 seconds].
182  //
183  // * For [Pub/Sub targets][google.cloud.scheduler.v1.Job.pubsub_target], this
184  // field is ignored.
185  google.protobuf.Duration attempt_deadline = 22;
186}
187
188// Settings that determine the retry behavior.
189//
190// By default, if a job does not complete successfully (meaning that
191// an acknowledgement is not received from the handler, then it will be retried
192// with exponential backoff according to the settings in
193// [RetryConfig][google.cloud.scheduler.v1.RetryConfig].
194message RetryConfig {
195  // The number of attempts that the system will make to run a job using the
196  // exponential backoff procedure described by
197  // [max_doublings][google.cloud.scheduler.v1.RetryConfig.max_doublings].
198  //
199  // The default value of retry_count is zero.
200  //
201  // If retry_count is zero, a job attempt will *not* be retried if
202  // it fails. Instead the Cloud Scheduler system will wait for the
203  // next scheduled execution time.
204  //
205  // If retry_count is set to a non-zero number then Cloud Scheduler
206  // will retry failed attempts, using exponential backoff,
207  // retry_count times, or until the next scheduled execution time,
208  // whichever comes first.
209  //
210  // Values greater than 5 and negative values are not allowed.
211  int32 retry_count = 1;
212
213  // The time limit for retrying a failed job, measured from time when an
214  // execution was first attempted. If specified with
215  // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count], the job
216  // will be retried until both limits are reached.
217  //
218  // The default value for max_retry_duration is zero, which means retry
219  // duration is unlimited.
220  google.protobuf.Duration max_retry_duration = 2;
221
222  // The minimum amount of time to wait before retrying a job after
223  // it fails.
224  //
225  // The default value of this field is 5 seconds.
226  google.protobuf.Duration min_backoff_duration = 3;
227
228  // The maximum amount of time to wait before retrying a job after
229  // it fails.
230  //
231  // The default value of this field is 1 hour.
232  google.protobuf.Duration max_backoff_duration = 4;
233
234  // The time between retries will double `max_doublings` times.
235  //
236  // A job's retry interval starts at
237  // [min_backoff_duration][google.cloud.scheduler.v1.RetryConfig.min_backoff_duration],
238  // then doubles `max_doublings` times, then increases linearly, and finally
239  // retries at intervals of
240  // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration]
241  // up to [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count]
242  // times.
243  //
244  // For example, if
245  // [min_backoff_duration][google.cloud.scheduler.v1.RetryConfig.min_backoff_duration]
246  // is 10s,
247  // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration]
248  // is 300s, and `max_doublings` is 3, then the a job will first be retried in
249  // 10s. The retry interval will double three times, and then increase linearly
250  // by 2^3 * 10s.  Finally, the job will retry at intervals of
251  // [max_backoff_duration][google.cloud.scheduler.v1.RetryConfig.max_backoff_duration]
252  // until the job has been attempted
253  // [retry_count][google.cloud.scheduler.v1.RetryConfig.retry_count] times.
254  // Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s,
255  // 300s, ....
256  //
257  // The default value of this field is 5.
258  int32 max_doublings = 5;
259}
260