Resource: Task
A unit of scheduled work.
JSON representation |
---|
{ "name": string, "scheduleTime": string, "createTime": string, "dispatchDeadline": string, "dispatchCount": integer, "responseCount": integer, "firstAttempt": { object ( |
Fields | |
---|---|
name |
Optionally caller-specified in The task name. The task name must have the following format:
|
scheduleTime |
The time when the task is scheduled to be attempted or retried.
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: |
createTime |
Output only. The time that the task was created.
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: |
dispatchDeadline |
The deadline for requests sent to the worker. If the worker does not respond by this deadline then the request is cancelled and the attempt is marked as a Note that when the request is cancelled, Cloud Tasks will stop listening for the response, but whether the worker stops processing depends on the worker. For example, if the worker is stuck, it may not react to cancelled requests. The default and maximum values depend on the type of request:
The value must be given as a string that indicates the length of time (in seconds) followed by |
dispatchCount |
Output only. The number of attempts dispatched. This count includes attempts which have been dispatched but haven't received a response. |
responseCount |
Output only. The number of attempts which have received a response. |
firstAttempt |
Output only. The status of the task's first attempt. Only |
lastAttempt |
Output only. The status of the task's last attempt. |
view |
Output only. The view specifies which subset of the |
Union field message_type . Required. The message to send to the worker. message_type can be only one of the following: |
|
appEngineHttpRequest |
HTTP request that is sent to the App Engine app handler. An App Engine task is a task that has |
httpRequest |
HTTP request that is sent to the worker. An HTTP task is a task that has |
AppEngineHttpRequest
App Engine HTTP request.
The message defines the HTTP request that is sent to an App Engine app when the task is dispatched.
Using AppEngineHttpRequest
requires appengine.applications.get
Google IAM permission for the project and the following scope:
https://www.googleapis.com/auth/cloud-platform
The task will be delivered to the App Engine app which belongs to the same project as the queue. For more information, see How Requests are Routed and how routing is affected by dispatch files. Traffic is encrypted during transport and never leaves Google datacenters. Because this traffic is carried over a communication mechanism internal to Google, you cannot explicitly set the protocol (for example, HTTP or HTTPS). The request to the handler, however, will appear to have used the HTTP protocol.
The AppEngineRouting
used to construct the URL that the task is delivered to can be set at the queue-level or task-level:
- If
appEngineRoutingOverride is set on the queue
, this value is used for all tasks in the queue, no matter what the setting is for thetask-level appEngineRouting
.
The url
that the task will be sent to is:
url =
host
+
relativeUri
Tasks can be dispatched to secure app handlers, unsecure app handlers, and URIs restricted with login:
admin
. Because tasks are not run as any user, they cannot be dispatched to URIs restricted with login:
required
Task dispatches also do not follow redirects.
The task attempt has succeeded if the app's request handler returns an HTTP response code in the range [200
- 299
]. The task attempt has failed if the app's handler returns a non-2xx response code or Cloud Tasks does not receive response before the deadline
. Failed tasks will be retried according to the retry configuration
. 503
(Service Unavailable) is considered an App Engine system error instead of an application error and will cause Cloud Tasks' traffic congestion control to temporarily throttle the queue's dispatches. Unlike other types of task targets, a 429
(Too Many Requests) response from an app handler does not cause traffic congestion control to throttle the queue.
JSON representation |
---|
{ "httpMethod": enum ( |
Fields | |
---|---|
httpMethod |
The HTTP method to use for the request. The default is POST. The app's request handler for the task's target URL must be able to handle HTTP requests with this httpMethod, otherwise the task attempt fails with error code 405 (Method Not Allowed). See Writing a push task request handler and the App Engine documentation for your runtime on How Requests are Handled. |
appEngineRouting |
Task-level setting for App Engine routing.
|
relativeUri |
The relative URI. The relative URI must begin with "/" and must be a valid HTTP relative URI. It can contain a path and query string arguments. If the relative URI is empty, then the root path "/" will be used. No spaces are allowed, and the maximum length allowed is 2083 characters. |
headers |
HTTP request headers. This map contains the header field names and values. Headers can be set when the Cloud Tasks sets some headers to default values:
If the task has a
The headers below cannot be set or overridden:
In addition, Cloud Tasks sets some headers when the task is dispatched, such as headers containing information about the task; see request headers. These headers are set only when the task is dispatched, so they are not visible when the task is returned in a Cloud Tasks response. Although there is no specific limit for the maximum number of headers or the size, there is a limit on the maximum size of the An object containing a list of |
body |
HTTP request body. A request body is allowed only if the HTTP method is POST or PUT. It is an error to set a body on a task with an incompatible A base64-encoded string. |
HttpRequest
HTTP request.
The task will be pushed to the worker as an HTTP request. If the worker or the redirected worker acknowledges the task by returning a successful HTTP response code ([200
- 299
]), the task will be removed from the queue. If any other HTTP response code is returned or no response is received, the task will be retried according to the following:
User-specified throttling:
retry configuration
,rate limits
, and thequeue's state
.System throttling: To prevent the worker from overloading, Cloud Tasks may temporarily reduce the queue's effective rate. User-specified settings will not be changed.
System throttling happens because:
Cloud Tasks backs off on all errors. Normally the backoff specified in
rate limits
will be used. But if the worker returns429
(Too Many Requests),503
(Service Unavailable), or the rate of errors is high, Cloud Tasks will use a higher backoff rate. The retry specified in theRetry-After
HTTP response header is considered.To prevent traffic spikes and to smooth sudden increases in traffic, dispatches ramp up slowly when the queue is newly created or idle and if large numbers of tasks suddenly become available to dispatch (due to spikes in create task rates, the queue being unpaused, or many tasks that are scheduled at the same time).
JSON representation |
---|
{ "url": string, "httpMethod": enum ( |
Fields | |
---|---|
url |
Required. The full url path that the request will be sent to. This string must begin with either "http://" or "https://". Some examples are: The |
httpMethod |
The HTTP method to use for the request. The default is POST. |
headers |
HTTP request headers. This map contains the header field names and values. Headers can be set when the These headers represent a subset of the headers that will accompany the task's HTTP request. Some HTTP request headers will be ignored or replaced. A partial list of headers that will be ignored or replaced is:
Headers which can have multiple values (according to RFC2616) can be specified using comma-separated values. The size of the headers must be less than 80KB. An object containing a list of |
body |
HTTP request body. A request body is allowed only if the A base64-encoded string. |
Union field If specified, all |
|
oauthToken |
If specified, an OAuth token will be generated and attached as an This type of authorization should generally only be used when calling Google APIs hosted on *.googleapis.com. |
oidcToken |
If specified, an OIDC token will be generated and attached as an This type of authorization can be used for many scenarios, including calling Cloud Run, or endpoints where you intend to validate the token yourself. |
Attempt
The status of a task attempt.
JSON representation |
---|
{
"scheduleTime": string,
"dispatchTime": string,
"responseTime": string,
"responseStatus": {
object ( |
Fields | |
---|---|
scheduleTime |
Output only. The time that this attempt was scheduled.
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: |
dispatchTime |
Output only. The time that this attempt was dispatched.
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: |
responseTime |
Output only. The time that this attempt response was received.
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: |
responseStatus |
Output only. The response from the worker for this attempt. If |
View
The view specifies a subset of Task
data.
When a task is returned in a response, not all information is retrieved by default because some data, such as payloads, might be desirable to return only when needed because of its large size or because of the sensitivity of data that it contains.
Enums | |
---|---|
VIEW_UNSPECIFIED |
Unspecified. Defaults to BASIC. |
BASIC |
The basic view omits fields which can be large or can contain sensitive data. This view does not include the |
FULL |
All information is returned. Authorization for |
Methods |
|
---|---|
|
Creates and buffers a new task without the need to explicitly define a Task message. |
|
Creates a task and adds it to a queue. |
|
Deletes a task. |
|
Gets a task. |
|
Lists the tasks in a queue. |
|
Forces a task to run now. |