queue.proto 15 KB

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