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