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