queue.proto 19 KB

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