Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit faa2027

Browse filesBrowse files
authored
Update task sample comments (GoogleCloudPlatform#2156)
* Update task comments * Update readme * Update queue name
1 parent 8a64381 commit faa2027
Copy full SHA for faa2027

File tree

Expand file treeCollapse file tree

5 files changed

+20
-32
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+20
-32
lines changed

‎tasks/README.md

Copy file name to clipboardExpand all lines: tasks/README.md
+12-24Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,17 @@
33
[![Open in Cloud Shell][shell_img]][shell_link]
44

55
[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png
6-
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=appengine/flexible/tasks/README.md
6+
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=tasks/README.md
77

8-
Sample command-line programs for interacting with the Cloud Tasks API
9-
.
10-
11-
App Engine queues push tasks to an App Engine HTTP target. This directory
12-
contains both the App Engine app to deploy, as well as the snippets to run
13-
locally to push tasks to it, which could also be called on App Engine.
8+
This sample demonstrates how to use the
9+
[Cloud Tasks](https://cloud.google.com/tasks/docs/) client library.
1410

1511
`create_http_task.py` is a simple command-line program to create
1612
tasks to be pushed to an URL endpoint.
1713

1814
`create_http_task_with_token.py` is a simple command-line program to create
1915
tasks to be pushed to an URL endpoint with authorization header.
2016

21-
`main.py` is the main App Engine app. This app serves as an endpoint to receive
22-
App Engine task attempts.
23-
24-
`app.yaml` configures the App Engine app.
25-
26-
2717
## Prerequisites to run locally:
2818

2919
Please refer to [Setting Up a Python Development Environment](https://cloud.google.com/python/setup).
@@ -35,15 +25,13 @@ To set up authentication, please refer to our
3525

3626
## Creating a queue
3727

38-
To create a queue using the Cloud SDK, use the following gcloud command:
28+
To create a queue (named `my-queue`) using the Cloud SDK, use the following
29+
gcloud command:
3930

4031
```
41-
gcloud beta tasks queues create-app-engine-queue my-appengine-queue
32+
gcloud beta tasks queues create my-queue
4233
```
4334

44-
Note: A newly created queue will route to the default App Engine service and
45-
version unless configured to do otherwise.
46-
4735
## Run the Sample Using the Command Line
4836

4937
Set environment variables:
@@ -58,25 +46,25 @@ Then the queue ID, as specified at queue creation time. Queue IDs already
5846
created can be listed with `gcloud beta tasks queues list`.
5947

6048
```
61-
export QUEUE_ID=my-appengine-queue
49+
export QUEUE_ID=my-queue
6250
```
6351

6452
And finally the location ID, which can be discovered with
65-
`gcloud beta tasks queues describe $QUEUE_ID`, with the location embedded in
53+
`gcloud beta tasks queues describe my-queue`, with the location embedded in
6654
the "name" value (for instance, if the name is
67-
"projects/my-project/locations/us-central1/queues/my-appengine-queue", then the
55+
"projects/my-project/locations/us-central1/queues/my-queue", then the
6856
location is "us-central1").
6957

7058
```
7159
export LOCATION_ID=us-central1
7260
```
7361

74-
### Using HTTP Push Queues
62+
### Creating Tasks with HTTP Targets
7563

7664
Set an environment variable for the endpoint to your task handler. This is an
77-
example url to send requests to the App Engine task handler:
65+
example url:
7866
```
79-
export URL=https://<project_id>.appspot.com/example_task_handler
67+
export URL=https://example.com/task_handler
8068
```
8169

8270
Running the sample will create a task and send the task to the specific URL

‎tasks/create_http_task.py

Copy file name to clipboardExpand all lines: tasks/create_http_task.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def create_http_task(project,
3535

3636
# TODO(developer): Uncomment these lines and replace with your values.
3737
# project = 'my-project-id'
38-
# queue = 'my-appengine-queue'
38+
# queue = 'my-queue'
3939
# location = 'us-central1'
40-
# url = 'https://<project-id>.appspot.com/example_task_handler'
40+
# url = 'https://example.com/task_handler'
4141
# payload = 'hello'
4242

4343
# Construct the fully qualified queue name.

‎tasks/create_http_task_test.py

Copy file name to clipboardExpand all lines: tasks/create_http_task_test.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
TEST_PROJECT_ID = os.getenv('GCLOUD_PROJECT')
2020
TEST_LOCATION = os.getenv('TEST_QUEUE_LOCATION', 'us-central1')
21-
TEST_QUEUE_NAME = os.getenv('TEST_QUEUE_NAME', 'my-appengine-queue')
21+
TEST_QUEUE_NAME = os.getenv('TEST_QUEUE_NAME', 'my-queue')
2222

2323

2424
def test_create_http_task():
25-
url = 'https://example.appspot.com/example_task_handler'
25+
url = 'https://example.com/task_handler'
2626
result = create_http_task.create_http_task(
2727
TEST_PROJECT_ID, TEST_QUEUE_NAME, TEST_LOCATION, url)
2828
assert TEST_QUEUE_NAME in result.name

‎tasks/create_http_task_with_token.py

Copy file name to clipboardExpand all lines: tasks/create_http_task_with_token.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def create_http_task(project,
3535

3636
# TODO(developer): Uncomment these lines and replace with your values.
3737
# project = 'my-project-id'
38-
# queue = 'my-appengine-queue'
38+
# queue = 'my-queue'
3939
# location = 'us-central1'
40-
# url = 'https://example.com/example_task_handler'
40+
# url = 'https://example.com/task_handler'
4141
# payload = 'hello'
4242

4343
# Construct the fully qualified queue name.

‎tasks/create_http_task_with_token_test.py

Copy file name to clipboardExpand all lines: tasks/create_http_task_with_token_test.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818

1919
TEST_PROJECT_ID = os.getenv('GCLOUD_PROJECT')
2020
TEST_LOCATION = os.getenv('TEST_QUEUE_LOCATION', 'us-central1')
21-
TEST_QUEUE_NAME = os.getenv('TEST_QUEUE_NAME', 'my-appengine-queue')
21+
TEST_QUEUE_NAME = os.getenv('TEST_QUEUE_NAME', 'my-queue')
2222
TEST_SERVICE_ACCOUNT = (
2323
'test-run-invoker@python-docs-samples-tests.iam.gserviceaccount.com')
2424

2525

2626
def test_create_http_task_with_token():
27-
url = 'https://example.com/example_task_handler'
27+
url = 'https://example.com/task_handler'
2828
result = create_http_task_with_token.create_http_task(TEST_PROJECT_ID,
2929
TEST_QUEUE_NAME,
3030
TEST_LOCATION,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.