queue.proto 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. // Copyright 2019 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. //
  15. syntax = "proto3";
  16. package google.cloud.tasks.v2;
  17. import "google/api/resource.proto";
  18. import "google/cloud/tasks/v2/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/v2;tasks";
  23. option java_multiple_files = true;
  24. option java_outer_classname = "QueueProto";
  25. option java_package = "com.google.cloud.tasks.v2";
  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, queue 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.
  50. PAUSED = 2;
  51. // The queue is disabled.
  52. //
  53. // A queue becomes `DISABLED` when
  54. // [queue.yaml](https://cloud.google.com/appengine/docs/python/config/queueref)
  55. // or
  56. // [queue.xml](https://cloud.google.com/appengine/docs/standard/java/config/queueref)
  57. // is uploaded which does not contain the queue. You cannot directly disable
  58. // a queue.
  59. //
  60. // When a queue is disabled, tasks can still be added to a queue
  61. // but the tasks are not dispatched.
  62. //
  63. // To permanently delete this queue and all of its tasks, call
  64. // [DeleteQueue][google.cloud.tasks.v2.CloudTasks.DeleteQueue].
  65. DISABLED = 3;
  66. }
  67. // Caller-specified and required in [CreateQueue][google.cloud.tasks.v2.CloudTasks.CreateQueue],
  68. // after which it becomes output only.
  69. //
  70. // The queue name.
  71. //
  72. // The queue name must have the following format:
  73. // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
  74. //
  75. // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
  76. // hyphens (-), colons (:), or periods (.).
  77. // For more information, see
  78. // [Identifying
  79. // projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
  80. // * `LOCATION_ID` is the canonical ID for the queue's location.
  81. // The list of available locations can be obtained by calling
  82. // [ListLocations][google.cloud.location.Locations.ListLocations].
  83. // For more information, see https://cloud.google.com/about/locations/.
  84. // * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or
  85. // hyphens (-). The maximum length is 100 characters.
  86. string name = 1;
  87. // Overrides for
  88. // [task-level app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing].
  89. // These settings apply only to
  90. // [App Engine tasks][google.cloud.tasks.v2.AppEngineHttpRequest] in this queue.
  91. // [Http tasks][google.cloud.tasks.v2.HttpRequest] are not affected.
  92. //
  93. // If set, `app_engine_routing_override` is used for all
  94. // [App Engine tasks][google.cloud.tasks.v2.AppEngineHttpRequest] in the queue, no matter what the
  95. // setting is for the
  96. // [task-level app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing].
  97. AppEngineRouting app_engine_routing_override = 2;
  98. // Rate limits for task dispatches.
  99. //
  100. // [rate_limits][google.cloud.tasks.v2.Queue.rate_limits] and [retry_config][google.cloud.tasks.v2.Queue.retry_config] are
  101. // related because they both control task attempts. However they control task
  102. // attempts in different ways:
  103. //
  104. // * [rate_limits][google.cloud.tasks.v2.Queue.rate_limits] controls the total rate of
  105. // dispatches from a queue (i.e. all traffic dispatched from the
  106. // queue, regardless of whether the dispatch is from a first
  107. // attempt or a retry).
  108. // * [retry_config][google.cloud.tasks.v2.Queue.retry_config] controls what happens to
  109. // particular a task after its first attempt fails. That is,
  110. // [retry_config][google.cloud.tasks.v2.Queue.retry_config] controls task retries (the
  111. // second attempt, third attempt, etc).
  112. //
  113. // The queue's actual dispatch rate is the result of:
  114. //
  115. // * Number of tasks in the queue
  116. // * User-specified throttling: [rate_limits][google.cloud.tasks.v2.Queue.rate_limits],
  117. // [retry_config][google.cloud.tasks.v2.Queue.retry_config], and the
  118. // [queue's state][google.cloud.tasks.v2.Queue.state].
  119. // * System throttling due to `429` (Too Many Requests) or `503` (Service
  120. // Unavailable) responses from the worker, high error rates, or to smooth
  121. // sudden large traffic spikes.
  122. RateLimits rate_limits = 3;
  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 = 4;
  134. // Output only. The state of the queue.
  135. //
  136. // `state` can only be changed by called
  137. // [PauseQueue][google.cloud.tasks.v2.CloudTasks.PauseQueue],
  138. // [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue], or uploading
  139. // [queue.yaml/xml](https://cloud.google.com/appengine/docs/python/config/queueref).
  140. // [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue] cannot be used to change `state`.
  141. State state = 5;
  142. // Output only. The last time this queue was purged.
  143. //
  144. // All tasks that were [created][google.cloud.tasks.v2.Task.create_time] before this time
  145. // were purged.
  146. //
  147. // A queue can be purged using [PurgeQueue][google.cloud.tasks.v2.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 = 6;
  154. // Configuration options for writing logs to
  155. // [Stackdriver Logging](https://cloud.google.com/logging/docs/). If this
  156. // field is unset, then no logs are written.
  157. StackdriverLoggingConfig stackdriver_logging_config = 9;
  158. }
  159. // Rate limits.
  160. //
  161. // This message determines the maximum rate that tasks can be dispatched by a
  162. // queue, regardless of whether the dispatch is a first task attempt or a retry.
  163. //
  164. // Note: The debugging command, [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask], will run a task
  165. // even if the queue has reached its [RateLimits][google.cloud.tasks.v2.RateLimits].
  166. message RateLimits {
  167. // The maximum rate at which tasks are dispatched from this queue.
  168. //
  169. // If unspecified when the queue is created, Cloud Tasks will pick the
  170. // default.
  171. //
  172. // * The maximum allowed value is 500.
  173. //
  174. //
  175. // This field has the same meaning as
  176. // [rate in
  177. // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#rate).
  178. double max_dispatches_per_second = 1;
  179. // Output only. The max burst size.
  180. //
  181. // Max burst size limits how fast tasks in queue are processed when
  182. // many tasks are in the queue and the rate is high. This field
  183. // allows the queue to have a high rate so processing starts shortly
  184. // after a task is enqueued, but still limits resource usage when
  185. // many tasks are enqueued in a short period of time.
  186. //
  187. // The [token bucket](https://wikipedia.org/wiki/Token_Bucket)
  188. // algorithm is used to control the rate of task dispatches. Each
  189. // queue has a token bucket that holds tokens, up to the maximum
  190. // specified by `max_burst_size`. Each time a task is dispatched, a
  191. // token is removed from the bucket. Tasks will be dispatched until
  192. // the queue's bucket runs out of tokens. The bucket will be
  193. // continuously refilled with new tokens based on
  194. // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second].
  195. //
  196. // Cloud Tasks will pick the value of `max_burst_size` based on the
  197. // value of
  198. // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second].
  199. //
  200. // For queues that were created or updated using
  201. // `queue.yaml/xml`, `max_burst_size` is equal to
  202. // [bucket_size](https://cloud.google.com/appengine/docs/standard/python/config/queueref#bucket_size).
  203. // Since `max_burst_size` is output only, if
  204. // [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue] is called on a queue
  205. // created by `queue.yaml/xml`, `max_burst_size` will be reset based
  206. // on the value of
  207. // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second],
  208. // regardless of whether
  209. // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second]
  210. // is updated.
  211. //
  212. int32 max_burst_size = 2;
  213. // The maximum number of concurrent tasks that Cloud Tasks allows
  214. // to be dispatched for this queue. After this threshold has been
  215. // reached, Cloud Tasks stops dispatching tasks until the number of
  216. // concurrent requests decreases.
  217. //
  218. // If unspecified when the queue is created, Cloud Tasks will pick the
  219. // default.
  220. //
  221. //
  222. // The maximum allowed value is 5,000.
  223. //
  224. //
  225. // This field has the same meaning as
  226. // [max_concurrent_requests in
  227. // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#max_concurrent_requests).
  228. int32 max_concurrent_dispatches = 3;
  229. }
  230. // Retry config.
  231. //
  232. // These settings determine when a failed task attempt is retried.
  233. message RetryConfig {
  234. // Number of attempts per task.
  235. //
  236. // Cloud Tasks will attempt the task `max_attempts` times (that is, if the
  237. // first attempt fails, then there will be `max_attempts - 1` retries). Must
  238. // be >= -1.
  239. //
  240. // If unspecified when the queue is created, Cloud Tasks will pick the
  241. // default.
  242. //
  243. // -1 indicates unlimited attempts.
  244. //
  245. // This field has the same meaning as
  246. // [task_retry_limit in
  247. // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
  248. int32 max_attempts = 1;
  249. // If positive, `max_retry_duration` specifies the time limit for
  250. // retrying a failed task, measured from when the task was first
  251. // attempted. Once `max_retry_duration` time has passed *and* the
  252. // task has been attempted [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts]
  253. // times, no further attempts will be made and the task will be
  254. // deleted.
  255. //
  256. // If zero, then the task age is unlimited.
  257. //
  258. // If unspecified when the queue is created, Cloud Tasks will pick the
  259. // default.
  260. //
  261. //
  262. // `max_retry_duration` will be truncated to the nearest second.
  263. //
  264. // This field has the same meaning as
  265. // [task_age_limit in
  266. // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
  267. google.protobuf.Duration max_retry_duration = 2;
  268. // A task will be [scheduled][google.cloud.tasks.v2.Task.schedule_time] for retry between
  269. // [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff] and
  270. // [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] duration after it fails,
  271. // if the queue's [RetryConfig][google.cloud.tasks.v2.RetryConfig] specifies that the task should be
  272. // retried.
  273. //
  274. // If unspecified when the queue is created, Cloud Tasks will pick the
  275. // default.
  276. //
  277. //
  278. // `min_backoff` will be truncated to the nearest second.
  279. //
  280. // This field has the same meaning as
  281. // [min_backoff_seconds in
  282. // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
  283. google.protobuf.Duration min_backoff = 3;
  284. // A task will be [scheduled][google.cloud.tasks.v2.Task.schedule_time] for retry between
  285. // [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff] and
  286. // [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] duration after it fails,
  287. // if the queue's [RetryConfig][google.cloud.tasks.v2.RetryConfig] specifies that the task should be
  288. // retried.
  289. //
  290. // If unspecified when the queue is created, Cloud Tasks will pick the
  291. // default.
  292. //
  293. //
  294. // `max_backoff` will be truncated to the nearest second.
  295. //
  296. // This field has the same meaning as
  297. // [max_backoff_seconds in
  298. // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
  299. google.protobuf.Duration max_backoff = 4;
  300. // The time between retries will double `max_doublings` times.
  301. //
  302. // A task's retry interval starts at
  303. // [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff], then doubles
  304. // `max_doublings` times, then increases linearly, and finally
  305. // retries retries at intervals of
  306. // [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] up to
  307. // [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts] times.
  308. //
  309. // For example, if [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff] is 10s,
  310. // [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] is 300s, and
  311. // `max_doublings` is 3, then the a task will first be retried in
  312. // 10s. The retry interval will double three times, and then
  313. // increase linearly by 2^3 * 10s. Finally, the task will retry at
  314. // intervals of [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] until the
  315. // task has been attempted [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts]
  316. // times. Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s,
  317. // 240s, 300s, 300s, ....
  318. //
  319. // If unspecified when the queue is created, Cloud Tasks will pick the
  320. // default.
  321. //
  322. //
  323. // This field has the same meaning as
  324. // [max_doublings in
  325. // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
  326. int32 max_doublings = 5;
  327. }
  328. // Configuration options for writing logs to
  329. // [Stackdriver Logging](https://cloud.google.com/logging/docs/).
  330. message StackdriverLoggingConfig {
  331. // Specifies the fraction of operations to write to
  332. // [Stackdriver Logging](https://cloud.google.com/logging/docs/).
  333. // This field may contain any value between 0.0 and 1.0, inclusive.
  334. // 0.0 is the default and means that no operations are logged.
  335. double sampling_ratio = 1;
  336. }