1// Copyright 2020 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.tasks.v2beta3;
18
19import "google/api/field_behavior.proto";
20import "google/api/resource.proto";
21import "google/cloud/tasks/v2beta3/target.proto";
22import "google/protobuf/duration.proto";
23import "google/protobuf/timestamp.proto";
24
25option go_package = "cloud.google.com/go/cloudtasks/apiv2beta3/cloudtaskspb;cloudtaskspb";
26option java_multiple_files = true;
27option java_outer_classname = "QueueProto";
28option java_package = "com.google.cloud.tasks.v2beta3";
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.v2beta3.CloudTasks.DeleteQueue].
73    DISABLED = 3;
74  }
75
76  // The type of the queue.
77  enum Type {
78    // Default value.
79    TYPE_UNSPECIFIED = 0;
80
81    // A pull queue.
82    PULL = 1;
83
84    // A push queue.
85    PUSH = 2;
86  }
87
88  // Caller-specified and required in
89  // [CreateQueue][google.cloud.tasks.v2beta3.CloudTasks.CreateQueue], after
90  // which it becomes output only.
91  //
92  // The queue name.
93  //
94  // The queue name must have the following format:
95  // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
96  //
97  // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
98  //    hyphens (-), colons (:), or periods (.).
99  //    For more information, see
100  //    [Identifying
101  //    projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
102  // * `LOCATION_ID` is the canonical ID for the queue's location.
103  //    The list of available locations can be obtained by calling
104  //    [ListLocations][google.cloud.location.Locations.ListLocations].
105  //    For more information, see https://cloud.google.com/about/locations/.
106  // * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or
107  //   hyphens (-). The maximum length is 100 characters.
108  string name = 1;
109
110  oneof queue_type {
111    // [AppEngineHttpQueue][google.cloud.tasks.v2beta3.AppEngineHttpQueue]
112    // settings apply only to [App Engine
113    // tasks][google.cloud.tasks.v2beta3.AppEngineHttpRequest] in this queue.
114    // [Http tasks][google.cloud.tasks.v2beta3.HttpRequest] are not affected by
115    // this proto.
116    AppEngineHttpQueue app_engine_http_queue = 3;
117  }
118
119  // Rate limits for task dispatches.
120  //
121  // [rate_limits][google.cloud.tasks.v2beta3.Queue.rate_limits] and
122  // [retry_config][google.cloud.tasks.v2beta3.Queue.retry_config] are related
123  // because they both control task attempts. However they control task attempts
124  // in different ways:
125  //
126  // * [rate_limits][google.cloud.tasks.v2beta3.Queue.rate_limits] controls the
127  // total rate of
128  //   dispatches from a queue (i.e. all traffic dispatched from the
129  //   queue, regardless of whether the dispatch is from a first
130  //   attempt or a retry).
131  // * [retry_config][google.cloud.tasks.v2beta3.Queue.retry_config] controls
132  // what happens to
133  //   particular a task after its first attempt fails. That is,
134  //   [retry_config][google.cloud.tasks.v2beta3.Queue.retry_config] controls
135  //   task retries (the second attempt, third attempt, etc).
136  //
137  // The queue's actual dispatch rate is the result of:
138  //
139  // * Number of tasks in the queue
140  // * User-specified throttling:
141  // [rate_limits][google.cloud.tasks.v2beta3.Queue.rate_limits],
142  //   [retry_config][google.cloud.tasks.v2beta3.Queue.retry_config], and the
143  //   [queue's state][google.cloud.tasks.v2beta3.Queue.state].
144  // * System throttling due to `429` (Too Many Requests) or `503` (Service
145  //   Unavailable) responses from the worker, high error rates, or to smooth
146  //   sudden large traffic spikes.
147  RateLimits rate_limits = 4;
148
149  // Settings that determine the retry behavior.
150  //
151  // * For tasks created using Cloud Tasks: the queue-level retry settings
152  //   apply to all tasks in the queue that were created using Cloud Tasks.
153  //   Retry settings cannot be set on individual tasks.
154  // * For tasks created using the App Engine SDK: the queue-level retry
155  //   settings apply to all tasks in the queue which do not have retry settings
156  //   explicitly set on the task and were created by the App Engine SDK. See
157  //   [App Engine
158  //   documentation](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/retrying-tasks).
159  RetryConfig retry_config = 5;
160
161  // Output only. The state of the queue.
162  //
163  // `state` can only be changed by calling
164  // [PauseQueue][google.cloud.tasks.v2beta3.CloudTasks.PauseQueue],
165  // [ResumeQueue][google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue], or
166  // uploading
167  // [queue.yaml/xml](https://cloud.google.com/appengine/docs/python/config/queueref).
168  // [UpdateQueue][google.cloud.tasks.v2beta3.CloudTasks.UpdateQueue] cannot be
169  // used to change `state`.
170  State state = 6;
171
172  // Output only. The last time this queue was purged.
173  //
174  // All tasks that were [created][google.cloud.tasks.v2beta3.Task.create_time]
175  // before this time were purged.
176  //
177  // A queue can be purged using
178  // [PurgeQueue][google.cloud.tasks.v2beta3.CloudTasks.PurgeQueue], the [App
179  // Engine Task Queue SDK, or the Cloud
180  // Console](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/deleting-tasks-and-queues#purging_all_tasks_from_a_queue).
181  //
182  // Purge time will be truncated to the nearest microsecond. Purge
183  // time will be unset if the queue has never been purged.
184  google.protobuf.Timestamp purge_time = 7;
185
186  // The maximum amount of time that a task will be retained in
187  // this queue.
188  //
189  // Queues created by Cloud Tasks have a default `task_ttl` of 31 days.
190  // After a task has lived for `task_ttl`, the task will be deleted
191  // regardless of whether it was dispatched or not.
192  //
193  // The `task_ttl` for queues created via queue.yaml/xml is equal to the
194  // maximum duration because there is a
195  // [storage quota](https://cloud.google.com/appengine/quotas#Task_Queue) for
196  // these queues. To view the maximum valid duration, see the documentation for
197  // [Duration][google.protobuf.Duration].
198  google.protobuf.Duration task_ttl = 8;
199
200  // The task tombstone time to live (TTL).
201  //
202  // After a task is deleted or executed, the task's tombstone is
203  // retained for the length of time specified by `tombstone_ttl`.
204  // The tombstone is used by task de-duplication; another task with the same
205  // name can't be created until the tombstone has expired. For more information
206  // about task de-duplication, see the documentation for
207  // [CreateTaskRequest][google.cloud.tasks.v2beta3.CreateTaskRequest.task].
208  //
209  // Queues created by Cloud Tasks have a default `tombstone_ttl` of 1 hour.
210  google.protobuf.Duration tombstone_ttl = 9;
211
212  // Configuration options for writing logs to
213  // [Stackdriver Logging](https://cloud.google.com/logging/docs/). If this
214  // field is unset, then no logs are written.
215  StackdriverLoggingConfig stackdriver_logging_config = 10;
216
217  // Immutable. The type of a queue (push or pull).
218  //
219  // `Queue.type` is an immutable property of the queue that is set at the queue
220  // creation time. When left unspecified, the default value of `PUSH` is
221  // selected.
222  Type type = 11 [(google.api.field_behavior) = IMMUTABLE];
223
224  // Output only. The realtime, informational statistics for a queue. In order
225  // to receive the statistics the caller should include this field in the
226  // FieldMask.
227  QueueStats stats = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
228}
229
230// Rate limits.
231//
232// This message determines the maximum rate that tasks can be dispatched by a
233// queue, regardless of whether the dispatch is a first task attempt or a retry.
234//
235// Note: The debugging command,
236// [RunTask][google.cloud.tasks.v2beta3.CloudTasks.RunTask], will run a task
237// even if the queue has reached its
238// [RateLimits][google.cloud.tasks.v2beta3.RateLimits].
239message RateLimits {
240  // The maximum rate at which tasks are dispatched from this queue.
241  //
242  // If unspecified when the queue is created, Cloud Tasks will pick the
243  // default.
244  //
245  // * For [App Engine queues][google.cloud.tasks.v2beta3.AppEngineHttpQueue],
246  // the maximum allowed value
247  //   is 500.
248  //
249  //
250  // This field has the same meaning as
251  // [rate in
252  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#rate).
253  double max_dispatches_per_second = 1;
254
255  // The max burst size.
256  //
257  // Max burst size limits how fast tasks in queue are processed when
258  // many tasks are in the queue and the rate is high. This field
259  // allows the queue to have a high rate so processing starts shortly
260  // after a task is enqueued, but still limits resource usage when
261  // many tasks are enqueued in a short period of time.
262  //
263  // The [token bucket](https://wikipedia.org/wiki/Token_Bucket)
264  // algorithm is used to control the rate of task dispatches. Each
265  // queue has a token bucket that holds tokens, up to the maximum
266  // specified by `max_burst_size`. Each time a task is dispatched, a
267  // token is removed from the bucket. Tasks will be dispatched until
268  // the queue's bucket runs out of tokens. The bucket will be
269  // continuously refilled with new tokens based on
270  // [max_dispatches_per_second][google.cloud.tasks.v2beta3.RateLimits.max_dispatches_per_second].
271  //
272  // The default value of `max_burst_size` is picked by Cloud Tasks
273  // based on the value of
274  // [max_dispatches_per_second][google.cloud.tasks.v2beta3.RateLimits.max_dispatches_per_second].
275  //
276  // The maximum value of `max_burst_size` is 500.
277  //
278  // For App Engine queues that were created or updated using
279  // `queue.yaml/xml`, `max_burst_size` is equal to
280  // [bucket_size](https://cloud.google.com/appengine/docs/standard/python/config/queueref#bucket_size).
281  // If
282  // [UpdateQueue][google.cloud.tasks.v2beta3.CloudTasks.UpdateQueue] is called
283  // on a queue without explicitly setting a value for `max_burst_size`,
284  // `max_burst_size` value will get updated if
285  // [UpdateQueue][google.cloud.tasks.v2beta3.CloudTasks.UpdateQueue] is
286  // updating
287  // [max_dispatches_per_second][google.cloud.tasks.v2beta3.RateLimits.max_dispatches_per_second].
288  //
289  int32 max_burst_size = 2;
290
291  // The maximum number of concurrent tasks that Cloud Tasks allows
292  // to be dispatched for this queue. After this threshold has been
293  // reached, Cloud Tasks stops dispatching tasks until the number of
294  // concurrent requests decreases.
295  //
296  // If unspecified when the queue is created, Cloud Tasks will pick the
297  // default.
298  //
299  //
300  // The maximum allowed value is 5,000.
301  //
302  //
303  // This field has the same meaning as
304  // [max_concurrent_requests in
305  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#max_concurrent_requests).
306  int32 max_concurrent_dispatches = 3;
307}
308
309// Retry config.
310//
311// These settings determine when a failed task attempt is retried.
312message RetryConfig {
313  // Number of attempts per task.
314  //
315  // Cloud Tasks will attempt the task `max_attempts` times (that is, if the
316  // first attempt fails, then there will be `max_attempts - 1` retries). Must
317  // be >= -1.
318  //
319  // If unspecified when the queue is created, Cloud Tasks will pick the
320  // default.
321  //
322  // -1 indicates unlimited attempts.
323  //
324  // This field has the same meaning as
325  // [task_retry_limit in
326  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
327  int32 max_attempts = 1;
328
329  // If positive, `max_retry_duration` specifies the time limit for
330  // retrying a failed task, measured from when the task was first
331  // attempted. Once `max_retry_duration` time has passed *and* the
332  // task has been attempted
333  // [max_attempts][google.cloud.tasks.v2beta3.RetryConfig.max_attempts] times,
334  // no further attempts will be made and the task will be deleted.
335  //
336  // If zero, then the task age is unlimited.
337  //
338  // If unspecified when the queue is created, Cloud Tasks will pick the
339  // default.
340  //
341  //
342  // `max_retry_duration` will be truncated to the nearest second.
343  //
344  // This field has the same meaning as
345  // [task_age_limit in
346  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
347  google.protobuf.Duration max_retry_duration = 2;
348
349  // A task will be [scheduled][google.cloud.tasks.v2beta3.Task.schedule_time]
350  // for retry between
351  // [min_backoff][google.cloud.tasks.v2beta3.RetryConfig.min_backoff] and
352  // [max_backoff][google.cloud.tasks.v2beta3.RetryConfig.max_backoff] duration
353  // after it fails, if the queue's
354  // [RetryConfig][google.cloud.tasks.v2beta3.RetryConfig] specifies that the
355  // task should be retried.
356  //
357  // If unspecified when the queue is created, Cloud Tasks will pick the
358  // default.
359  //
360  //
361  // `min_backoff` will be truncated to the nearest second.
362  //
363  // This field has the same meaning as
364  // [min_backoff_seconds in
365  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
366  google.protobuf.Duration min_backoff = 3;
367
368  // A task will be [scheduled][google.cloud.tasks.v2beta3.Task.schedule_time]
369  // for retry between
370  // [min_backoff][google.cloud.tasks.v2beta3.RetryConfig.min_backoff] and
371  // [max_backoff][google.cloud.tasks.v2beta3.RetryConfig.max_backoff] duration
372  // after it fails, if the queue's
373  // [RetryConfig][google.cloud.tasks.v2beta3.RetryConfig] specifies that the
374  // task should be retried.
375  //
376  // If unspecified when the queue is created, Cloud Tasks will pick the
377  // default.
378  //
379  //
380  // `max_backoff` will be truncated to the nearest second.
381  //
382  // This field has the same meaning as
383  // [max_backoff_seconds in
384  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
385  google.protobuf.Duration max_backoff = 4;
386
387  // The time between retries will double `max_doublings` times.
388  //
389  // A task's retry interval starts at
390  // [min_backoff][google.cloud.tasks.v2beta3.RetryConfig.min_backoff], then
391  // doubles `max_doublings` times, then increases linearly, and finally retries
392  // at intervals of
393  // [max_backoff][google.cloud.tasks.v2beta3.RetryConfig.max_backoff] up to
394  // [max_attempts][google.cloud.tasks.v2beta3.RetryConfig.max_attempts] times.
395  //
396  // For example, if
397  // [min_backoff][google.cloud.tasks.v2beta3.RetryConfig.min_backoff] is 10s,
398  // [max_backoff][google.cloud.tasks.v2beta3.RetryConfig.max_backoff] is 300s,
399  // and `max_doublings` is 3, then the a task will first be retried in 10s. The
400  // retry interval will double three times, and then increase linearly by 2^3 *
401  // 10s.  Finally, the task will retry at intervals of
402  // [max_backoff][google.cloud.tasks.v2beta3.RetryConfig.max_backoff] until the
403  // task has been attempted
404  // [max_attempts][google.cloud.tasks.v2beta3.RetryConfig.max_attempts] times.
405  // Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s,
406  // 300s, ....
407  //
408  // If unspecified when the queue is created, Cloud Tasks will pick the
409  // default.
410  //
411  //
412  // This field has the same meaning as
413  // [max_doublings in
414  // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
415  int32 max_doublings = 5;
416}
417
418// Configuration options for writing logs to
419// [Stackdriver Logging](https://cloud.google.com/logging/docs/).
420message StackdriverLoggingConfig {
421  // Specifies the fraction of operations to write to
422  // [Stackdriver Logging](https://cloud.google.com/logging/docs/).
423  // This field may contain any value between 0.0 and 1.0, inclusive.
424  // 0.0 is the default and means that no operations are logged.
425  double sampling_ratio = 1;
426}
427
428// Statistics for a queue.
429message QueueStats {
430  // Output only. An estimation of the number of tasks in the queue, that is,
431  // the tasks in the queue that haven't been executed, the tasks in the queue
432  // which the queue has dispatched but has not yet received a reply for, and
433  // the failed tasks that the queue is retrying.
434  int64 tasks_count = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
435
436  // Output only. An estimation of the nearest time in the future where a task
437  // in the queue is scheduled to be executed.
438  google.protobuf.Timestamp oldest_estimated_arrival_time = 2
439      [(google.api.field_behavior) = OUTPUT_ONLY];
440
441  // Output only. The number of tasks that the queue has dispatched and received
442  // a reply for during the last minute. This variable counts both successful
443  // and non-successful executions.
444  int64 executed_last_minute_count = 3
445      [(google.api.field_behavior) = OUTPUT_ONLY];
446
447  // Output only. The number of requests that the queue has dispatched but has
448  // not received a reply for yet.
449  int64 concurrent_dispatches_count = 4
450      [(google.api.field_behavior) = OUTPUT_ONLY];
451
452  // Output only. The current maximum number of tasks per second executed by the
453  // queue. The maximum value of this variable is controlled by the RateLimits
454  // of the Queue. However, this value could be less to avoid overloading the
455  // endpoints tasks in the queue are targeting.
456  double effective_execution_rate = 5
457      [(google.api.field_behavior) = OUTPUT_ONLY];
458}
459