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