1// Copyright 2019 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//
15
16syntax = "proto3";
17
18package google.cloud.tasks.v2;
19
20import "google/api/resource.proto";
21import "google/cloud/tasks/v2/target.proto";
22import "google/protobuf/duration.proto";
23import "google/protobuf/timestamp.proto";
24
25option go_package = "cloud.google.com/go/cloudtasks/apiv2/cloudtaskspb;cloudtaskspb";
26option java_multiple_files = true;
27option java_outer_classname = "QueueProto";
28option java_package = "com.google.cloud.tasks.v2";
29
30// A queue is a container of related tasks. Queues are configured to manage
31// how those tasks are dispatched. Configurable properties include rate limits,
32// retry options, queue types, and others.
33message Queue {
34  option (google.api.resource) = {
35    type: "cloudtasks.googleapis.com/Queue"
36    pattern: "projects/{project}/locations/{location}/queues/{queue}"
37  };
38
39  // State of the queue.
40  enum State {
41    // Unspecified state.
42    STATE_UNSPECIFIED = 0;
43
44    // The queue is running. Tasks can be dispatched.
45    //
46    // If the queue was created using Cloud Tasks and the queue has
47    // had no activity (method calls or task dispatches) for 30 days,
48    // the queue may take a few minutes to re-activate. Some method
49    // calls may return [NOT_FOUND][google.rpc.Code.NOT_FOUND] and
50    // tasks may not be dispatched for a few minutes until the queue
51    // has been re-activated.
52    RUNNING = 1;
53
54    // Tasks are paused by the user. If the queue is paused then Cloud
55    // Tasks will stop delivering tasks from it, but more tasks can
56    // still be added to it by the user.
57    PAUSED = 2;
58
59    // The queue is disabled.
60    //
61    // A queue becomes `DISABLED` when
62    // [queue.yaml](https://cloud.google.com/appengine/docs/python/config/queueref)
63    // or
64    // [queue.xml](https://cloud.google.com/appengine/docs/standard/java/config/queueref)
65    // is uploaded which does not contain the queue. You cannot directly disable
66    // a queue.
67    //
68    // When a queue is disabled, tasks can still be added to a queue
69    // but the tasks are not dispatched.
70    //
71    // To permanently delete this queue and all of its tasks, call
72    // [DeleteQueue][google.cloud.tasks.v2.CloudTasks.DeleteQueue].
73    DISABLED = 3;
74  }
75
76  // Caller-specified and required in
77  // [CreateQueue][google.cloud.tasks.v2.CloudTasks.CreateQueue], after which it
78  // becomes output only.
79  //
80  // The queue name.
81  //
82  // The queue name must have the following format:
83  // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
84  //
85  // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
86  //    hyphens (-), colons (:), or periods (.).
87  //    For more information, see
88  //    [Identifying
89  //    projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
90  // * `LOCATION_ID` is the canonical ID for the queue's location.
91  //    The list of available locations can be obtained by calling
92  //    [ListLocations][google.cloud.location.Locations.ListLocations].
93  //    For more information, see https://cloud.google.com/about/locations/.
94  // * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or
95  //   hyphens (-). The maximum length is 100 characters.
96  string name = 1;
97
98  // Overrides for
99  // [task-level
100  // app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing].
101  // These settings apply only to
102  // [App Engine tasks][google.cloud.tasks.v2.AppEngineHttpRequest] in this
103  // queue. [Http tasks][google.cloud.tasks.v2.HttpRequest] are not affected.
104  //
105  // If set, `app_engine_routing_override` is used for all
106  // [App Engine tasks][google.cloud.tasks.v2.AppEngineHttpRequest] in the
107  // queue, no matter what the setting is for the [task-level
108  // app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing].
109  AppEngineRouting app_engine_routing_override = 2;
110
111  // Rate limits for task dispatches.
112  //
113  // [rate_limits][google.cloud.tasks.v2.Queue.rate_limits] and
114  // [retry_config][google.cloud.tasks.v2.Queue.retry_config] are related
115  // because they both control task attempts. However they control task attempts
116  // in different ways:
117  //
118  // * [rate_limits][google.cloud.tasks.v2.Queue.rate_limits] controls the total
119  // rate of
120  //   dispatches from a queue (i.e. all traffic dispatched from the
121  //   queue, regardless of whether the dispatch is from a first
122  //   attempt or a retry).
123  // * [retry_config][google.cloud.tasks.v2.Queue.retry_config] controls what
124  // happens to
125  //   particular a task after its first attempt fails. That is,
126  //   [retry_config][google.cloud.tasks.v2.Queue.retry_config] controls task
127  //   retries (the second attempt, third attempt, etc).
128  //
129  // The queue's actual dispatch rate is the result of:
130  //
131  // * Number of tasks in the queue
132  // * User-specified throttling:
133  // [rate_limits][google.cloud.tasks.v2.Queue.rate_limits],
134  //   [retry_config][google.cloud.tasks.v2.Queue.retry_config], and the
135  //   [queue's state][google.cloud.tasks.v2.Queue.state].
136  // * System throttling due to `429` (Too Many Requests) or `503` (Service
137  //   Unavailable) responses from the worker, high error rates, or to smooth
138  //   sudden large traffic spikes.
139  RateLimits rate_limits = 3;
140
141  // Settings that determine the retry behavior.
142  //
143  // * For tasks created using Cloud Tasks: the queue-level retry settings
144  //   apply to all tasks in the queue that were created using Cloud Tasks.
145  //   Retry settings cannot be set on individual tasks.
146  // * For tasks created using the App Engine SDK: the queue-level retry
147  //   settings apply to all tasks in the queue which do not have retry settings
148  //   explicitly set on the task and were created by the App Engine SDK. See
149  //   [App Engine
150  //   documentation](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/retrying-tasks).
151  RetryConfig retry_config = 4;
152
153  // Output only. The state of the queue.
154  //
155  // `state` can only be changed by called
156  // [PauseQueue][google.cloud.tasks.v2.CloudTasks.PauseQueue],
157  // [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue], or uploading
158  // [queue.yaml/xml](https://cloud.google.com/appengine/docs/python/config/queueref).
159  // [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue] cannot be used
160  // to change `state`.
161  State state = 5;
162
163  // Output only. The last time this queue was purged.
164  //
165  // All tasks that were [created][google.cloud.tasks.v2.Task.create_time]
166  // before this time were purged.
167  //
168  // A queue can be purged using
169  // [PurgeQueue][google.cloud.tasks.v2.CloudTasks.PurgeQueue], the [App Engine
170  // Task Queue SDK, or the Cloud
171  // Console](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/deleting-tasks-and-queues#purging_all_tasks_from_a_queue).
172  //
173  // Purge time will be truncated to the nearest microsecond. Purge
174  // time will be unset if the queue has never been purged.
175  google.protobuf.Timestamp purge_time = 6;
176
177  // Configuration options for writing logs to
178  // [Stackdriver Logging](https://cloud.google.com/logging/docs/). If this
179  // field is unset, then no logs are written.
180  StackdriverLoggingConfig stackdriver_logging_config = 9;
181}
182
183// Rate limits.
184//
185// This message determines the maximum rate that tasks can be dispatched by a
186// queue, regardless of whether the dispatch is a first task attempt or a retry.
187//
188// Note: The debugging command,
189// [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask], will run a task even if
190// the queue has reached its [RateLimits][google.cloud.tasks.v2.RateLimits].
191message RateLimits {
192  // The maximum rate at which tasks are dispatched from this queue.
193  //
194  // If unspecified when the queue is created, Cloud Tasks will pick the
195  // default.
196  //
197  // * The maximum allowed value is 500.
198  //
199  //
200  // This field has the same meaning as
201  // [rate in
202  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#rate).
203  double max_dispatches_per_second = 1;
204
205  // Output only. The max burst size.
206  //
207  // Max burst size limits how fast tasks in queue are processed when
208  // many tasks are in the queue and the rate is high. This field
209  // allows the queue to have a high rate so processing starts shortly
210  // after a task is enqueued, but still limits resource usage when
211  // many tasks are enqueued in a short period of time.
212  //
213  // The [token bucket](https://wikipedia.org/wiki/Token_Bucket)
214  // algorithm is used to control the rate of task dispatches. Each
215  // queue has a token bucket that holds tokens, up to the maximum
216  // specified by `max_burst_size`. Each time a task is dispatched, a
217  // token is removed from the bucket. Tasks will be dispatched until
218  // the queue's bucket runs out of tokens. The bucket will be
219  // continuously refilled with new tokens based on
220  // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second].
221  //
222  // Cloud Tasks will pick the value of `max_burst_size` based on the
223  // value of
224  // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second].
225  //
226  // For queues that were created or updated using
227  // `queue.yaml/xml`, `max_burst_size` is equal to
228  // [bucket_size](https://cloud.google.com/appengine/docs/standard/python/config/queueref#bucket_size).
229  // Since `max_burst_size` is output only, if
230  // [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue] is called on a
231  // queue created by `queue.yaml/xml`, `max_burst_size` will be reset based on
232  // the value of
233  // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second],
234  // regardless of whether
235  // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second]
236  // is updated.
237  //
238  int32 max_burst_size = 2;
239
240  // The maximum number of concurrent tasks that Cloud Tasks allows
241  // to be dispatched for this queue. After this threshold has been
242  // reached, Cloud Tasks stops dispatching tasks until the number of
243  // concurrent requests decreases.
244  //
245  // If unspecified when the queue is created, Cloud Tasks will pick the
246  // default.
247  //
248  //
249  // The maximum allowed value is 5,000.
250  //
251  //
252  // This field has the same meaning as
253  // [max_concurrent_requests in
254  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#max_concurrent_requests).
255  int32 max_concurrent_dispatches = 3;
256}
257
258// Retry config.
259//
260// These settings determine when a failed task attempt is retried.
261message RetryConfig {
262  // Number of attempts per task.
263  //
264  // Cloud Tasks will attempt the task `max_attempts` times (that is, if the
265  // first attempt fails, then there will be `max_attempts - 1` retries). Must
266  // be >= -1.
267  //
268  // If unspecified when the queue is created, Cloud Tasks will pick the
269  // default.
270  //
271  // -1 indicates unlimited attempts.
272  //
273  // This field has the same meaning as
274  // [task_retry_limit in
275  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
276  int32 max_attempts = 1;
277
278  // If positive, `max_retry_duration` specifies the time limit for
279  // retrying a failed task, measured from when the task was first
280  // attempted. Once `max_retry_duration` time has passed *and* the
281  // task has been attempted
282  // [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts] times, no
283  // further attempts will be made and the task will be deleted.
284  //
285  // If zero, then the task age is unlimited.
286  //
287  // If unspecified when the queue is created, Cloud Tasks will pick the
288  // default.
289  //
290  //
291  // `max_retry_duration` will be truncated to the nearest second.
292  //
293  // This field has the same meaning as
294  // [task_age_limit in
295  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
296  google.protobuf.Duration max_retry_duration = 2;
297
298  // A task will be [scheduled][google.cloud.tasks.v2.Task.schedule_time] for
299  // retry between [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff]
300  // and [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] duration
301  // after it fails, if the queue's
302  // [RetryConfig][google.cloud.tasks.v2.RetryConfig] specifies that the task
303  // should be retried.
304  //
305  // If unspecified when the queue is created, Cloud Tasks will pick the
306  // default.
307  //
308  //
309  // `min_backoff` will be truncated to the nearest second.
310  //
311  // This field has the same meaning as
312  // [min_backoff_seconds in
313  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
314  google.protobuf.Duration min_backoff = 3;
315
316  // A task will be [scheduled][google.cloud.tasks.v2.Task.schedule_time] for
317  // retry between [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff]
318  // and [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] duration
319  // after it fails, if the queue's
320  // [RetryConfig][google.cloud.tasks.v2.RetryConfig] specifies that the task
321  // should be retried.
322  //
323  // If unspecified when the queue is created, Cloud Tasks will pick the
324  // default.
325  //
326  //
327  // `max_backoff` will be truncated to the nearest second.
328  //
329  // This field has the same meaning as
330  // [max_backoff_seconds in
331  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
332  google.protobuf.Duration max_backoff = 4;
333
334  // The time between retries will double `max_doublings` times.
335  //
336  // A task's retry interval starts at
337  // [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff], then doubles
338  // `max_doublings` times, then increases linearly, and finally
339  // retries retries at intervals of
340  // [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] up to
341  // [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts] times.
342  //
343  // For example, if
344  // [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff] is 10s,
345  // [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] is 300s, and
346  // `max_doublings` is 3, then the a task will first be retried in
347  // 10s. The retry interval will double three times, and then
348  // increase linearly by 2^3 * 10s.  Finally, the task will retry at
349  // intervals of [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff]
350  // until the task has been attempted
351  // [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts] times. Thus,
352  // the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s, 300s, ....
353  //
354  // If unspecified when the queue is created, Cloud Tasks will pick the
355  // default.
356  //
357  //
358  // This field has the same meaning as
359  // [max_doublings in
360  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
361  int32 max_doublings = 5;
362}
363
364// Configuration options for writing logs to
365// [Stackdriver Logging](https://cloud.google.com/logging/docs/).
366message StackdriverLoggingConfig {
367  // Specifies the fraction of operations to write to
368  // [Stackdriver Logging](https://cloud.google.com/logging/docs/).
369  // This field may contain any value between 0.0 and 1.0, inclusive.
370  // 0.0 is the default and means that no operations are logged.
371  double sampling_ratio = 1;
372}
373