queue.proto 19 KB

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