Skip to content

Commit

Permalink
feat: add alpha support for HTTP triggers (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and JustinBeckwith committed Feb 25, 2019
1 parent b5bd215 commit c6524ed
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Google LLC.
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Google LLC.
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -92,6 +92,7 @@ message Queue {
oneof queue_type {
// [AppEngineHttpQueue][google.cloud.tasks.v2beta3.AppEngineHttpQueue] settings apply only to
// [App Engine tasks][google.cloud.tasks.v2beta3.AppEngineHttpRequest] in this queue.
// [Http tasks][google.cloud.tasks.v2beta3.HttpRequest] are not affected by this proto.
AppEngineHttpQueue app_engine_http_queue = 3;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Google LLC.
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,91 @@ option java_outer_classname = "TargetProto";
option java_package = "com.google.cloud.tasks.v2beta3";


// HTTP request.
//
// Warning: This is an [alpha](https://cloud.google.com/terms/launch-stages)
// feature. If you haven't already joined, you can [use this form to sign
// up](https://docs.google.com/forms/d/e/1FAIpQLSfc4uEy9CBHKYUSdnY1hdhKDCX7julVZHy3imOiR-XrU7bUNQ/viewform?usp=sf_link).
//
// 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 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][Queue.RetryConfig],
// [rate limits][Queue.RateLimits], and the [queue's state][google.cloud.tasks.v2beta3.Queue.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 backoffs on all errors. Normally the backoff specified in
// [rate limits][Queue.RateLimits] will be used. But if the worker returns
// `429` (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 the `Retry-After` HTTP response header is considered.
//
// * To prevent traffic spikes and to smooth sudden large traffic spikes,
// 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).
message HttpRequest {
// Required. The full url path that the request will be sent to.
//
// This string must begin with either "http://" or "https://". Some examples
// are: `http://acme.com` and `https://acme.com/sales:8080`. Cloud Tasks will
// encode some characters for safety and compatibility. The maximum allowed
// URL length is 2083 characters after encoding.
//
// The `Location` header response from a redirect response [`300` - `399`]
// may be followed. The redirect is not counted as a separate attempt.
string url = 1;

// The HTTP method to use for the request. The default is POST.
HttpMethod http_method = 2;

// HTTP request headers.
//
// This map contains the header field names and values.
// Headers can be set when the
// [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
//
// 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:
//
// * Host: This will be computed by Cloud Tasks and derived from
// [HttpRequest.url][google.cloud.tasks.v2beta3.HttpRequest.url].
// * Content-Length: This will be computed by Cloud Tasks.
// * User-Agent: This will be set to `"Google-Cloud-Tasks"`.
// * X-Google-*: Google use only.
// * X-AppEngine-*: Google use only.
//
// `Content-Type` won't be set by Cloud Tasks. You can explicitly set
// `Content-Type` to a media type when the
// [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
// For example, `Content-Type` can be set to `"application/octet-stream"` or
// `"application/json"`.
//
// 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.
map<string, string> headers = 3;

// HTTP request body.
//
// A request body is allowed only if the
// [HTTP method][google.cloud.tasks.v2beta3.HttpRequest.http_method] is POST, PUT, or PATCH. It is an
// error to set body on a task with an incompatible [HttpMethod][google.cloud.tasks.v2beta3.HttpMethod].
bytes body = 4;
}

// App Engine HTTP queue.
//
// The task will be delivered to the App Engine application hostname
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 Google LLC.
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -70,7 +70,8 @@ message Task {
// * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
// hyphens (-), colons (:), or periods (.).
// For more information, see
// [Identifying projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
// [Identifying
// projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
// * `LOCATION_ID` is the canonical ID for the task's location.
// The list of available locations can be obtained by calling
// [ListLocations][google.cloud.location.Locations.ListLocations].
Expand All @@ -87,6 +88,15 @@ message Task {
//
// An App Engine task is a task that has [AppEngineHttpRequest][google.cloud.tasks.v2beta3.AppEngineHttpRequest] set.
AppEngineHttpRequest app_engine_http_request = 3;

// HTTP request that is sent to the task's target.
//
// Warning: This is an [alpha](https://cloud.google.com/terms/launch-stages)
// feature. If you haven't already joined, you can [use this form to sign
// up](https://docs.google.com/forms/d/e/1FAIpQLSfc4uEy9CBHKYUSdnY1hdhKDCX7julVZHy3imOiR-XrU7bUNQ/viewform?usp=sf_link).
//
// An HTTP task is a task that has [HttpRequest][google.cloud.tasks.v2beta3.HttpRequest] set.
HttpRequest http_request = 11;
}

// The time when the task is scheduled to be attempted.
Expand All @@ -113,6 +123,9 @@ message Task {
//
// The default and maximum values depend on the type of request:
//
// * For [HTTP tasks][google.cloud.tasks.v2beta3.HttpRequest], the default is
// 10 minutes.
// The deadline must be in the interval [15 seconds, 30 minutes].
//
// * For [App Engine tasks][google.cloud.tasks.v2beta3.AppEngineHttpRequest], 0 indicates that the
// request has the default deadline. The default deadline depends on the
Expand All @@ -133,7 +146,7 @@ message Task {

// Output only. The number of attempts dispatched.
//
// This count includes tasks which have been dispatched but haven't
// This count includes attempts which have been dispatched but haven't
// received a response.
int32 dispatch_count = 6;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* @property {Object} appEngineHttpQueue
* AppEngineHttpQueue settings apply only to
* App Engine tasks in this queue.
* Http tasks are not affected by this proto.
*
* This object should have the same structure as [AppEngineHttpQueue]{@link google.cloud.tasks.v2beta3.AppEngineHttpQueue}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,101 @@
// Note: this file is purely for documentation. Any contents are not expected
// to be loaded as the JS file.

/**
* HTTP request.
*
* Warning: This is an [alpha](https://cloud.google.com/terms/launch-stages)
* feature. If you haven't already joined, you can [use this form to sign
* up](https://docs.google.com/forms/d/e/1FAIpQLSfc4uEy9CBHKYUSdnY1hdhKDCX7julVZHy3imOiR-XrU7bUNQ/viewform?usp=sf_link).
*
* 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 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 the queue'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 backoffs on all errors. Normally the backoff specified in
* rate limits will be used. But if the worker returns
* `429` (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 the `Retry-After` HTTP response header is considered.
*
* * To prevent traffic spikes and to smooth sudden large traffic spikes,
* 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).
*
* @property {string} 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: `http://acme.com` and `https://acme.com/sales:8080`. Cloud Tasks will
* encode some characters for safety and compatibility. The maximum allowed
* URL length is 2083 characters after encoding.
*
* The `Location` header response from a redirect response [`300` - `399`]
* may be followed. The redirect is not counted as a separate attempt.
*
* @property {number} httpMethod
* The HTTP method to use for the request. The default is POST.
*
* The number should be among the values of [HttpMethod]{@link google.cloud.tasks.v2beta3.HttpMethod}
*
* @property {Object.<string, string>} headers
* HTTP request headers.
*
* This map contains the header field names and values.
* Headers can be set when the
* task is created.
*
* 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:
*
* * Host: This will be computed by Cloud Tasks and derived from
* HttpRequest.url.
* * Content-Length: This will be computed by Cloud Tasks.
* * User-Agent: This will be set to `"Google-Cloud-Tasks"`.
* * X-Google-*: Google use only.
* * X-AppEngine-*: Google use only.
*
* `Content-Type` won't be set by Cloud Tasks. You can explicitly set
* `Content-Type` to a media type when the
* task is created.
* For example, `Content-Type` can be set to `"application/octet-stream"` or
* `"application/json"`.
*
* 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.
*
* @property {string} body
* HTTP request body.
*
* A request body is allowed only if the
* HTTP method is POST, PUT, or PATCH. It is an
* error to set body on a task with an incompatible HttpMethod.
*
* @typedef HttpRequest
* @memberof google.cloud.tasks.v2beta3
* @see [google.cloud.tasks.v2beta3.HttpRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/tasks/v2beta3/target.proto}
*/
const HttpRequest = {
// This is for documentation. Actual contents will be loaded by gRPC.
};

/**
* App Engine HTTP queue.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
* * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
* hyphens (-), colons (:), or periods (.).
* For more information, see
* [Identifying projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
* [Identifying
* projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
* * `LOCATION_ID` is the canonical ID for the task's location.
* The list of available locations can be obtained by calling
* ListLocations.
Expand All @@ -46,6 +47,17 @@
*
* This object should have the same structure as [AppEngineHttpRequest]{@link google.cloud.tasks.v2beta3.AppEngineHttpRequest}
*
* @property {Object} httpRequest
* HTTP request that is sent to the task's target.
*
* Warning: This is an [alpha](https://cloud.google.com/terms/launch-stages)
* feature. If you haven't already joined, you can [use this form to sign
* up](https://docs.google.com/forms/d/e/1FAIpQLSfc4uEy9CBHKYUSdnY1hdhKDCX7julVZHy3imOiR-XrU7bUNQ/viewform?usp=sf_link).
*
* An HTTP task is a task that has HttpRequest set.
*
* This object should have the same structure as [HttpRequest]{@link google.cloud.tasks.v2beta3.HttpRequest}
*
* @property {Object} scheduleTime
* The time when the task is scheduled to be attempted.
*
Expand Down Expand Up @@ -75,6 +87,9 @@
*
* The default and maximum values depend on the type of request:
*
* * For HTTP tasks, the default is
* 10 minutes.
* The deadline must be in the interval [15 seconds, 30 minutes].
*
* * For App Engine tasks, 0 indicates that the
* request has the default deadline. The default deadline depends on the
Expand All @@ -97,7 +112,7 @@
* @property {number} dispatchCount
* Output only. The number of attempts dispatched.
*
* This count includes tasks which have been dispatched but haven't
* This count includes attempts which have been dispatched but haven't
* received a response.
*
* @property {number} responseCount
Expand Down
10 changes: 5 additions & 5 deletions packages/google-cloud-tasks/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"updateTime": "2019-02-13T12:27:54.843455Z",
"updateTime": "2019-02-24T12:23:17.381412Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.16.13",
"dockerImage": "googleapis/artman@sha256:5fd9aee1d82a00cebf425c8fa431f5457539562f5867ad9c54370f0ec9a7ccaa"
"version": "0.16.14",
"dockerImage": "googleapis/artman@sha256:f3d61ae45abaeefb6be5f228cda22732c2f1b00fb687c79c4bd4f2c42bb1e1a7"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "ca61898878f0926dd9dcc68ba90764f17133efe4",
"internalRef": "233680013"
"sha": "59f2494f1b00511bbb813d647cfbe95c949de0fe",
"internalRef": "235350912"
}
},
{
Expand Down

0 comments on commit c6524ed

Please sign in to comment.