queue.proto 19 KB

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