@@ -62,17 +62,17 @@ def task_queue(
62
62
extension_id : Optional [str ] = None ,
63
63
app : Optional [App ] = None
64
64
) -> TaskQueue :
65
- """Creates a referance to a TaskQueue for a given function name.
65
+ """Creates a reference to a TaskQueue for a given function name.
66
66
67
67
The function name can be either:
68
- 1) A fully qualified function resource name:
68
+ 1. A fully qualified function resource name:
69
69
`projects/{project-id}/locations/{location-id}/functions/{function-name}`
70
70
71
- 2) A partial resource name with location and function name, in which case
71
+ 2. A partial resource name with location and function name, in which case
72
72
the runtime project ID is used:
73
73
`locations/{location-id}/functions/{function-name}`
74
74
75
- 3) A partial function name, in which case the runtime project ID and the
75
+ 3. A partial function name, in which case the runtime project ID and the
76
76
default location, `us-central1`, is used:
77
77
`{function-name}`
78
78
@@ -180,7 +180,7 @@ def enqueue(self, task_data: Any, opts: Optional[TaskOptions] = None) -> str:
180
180
raise _FunctionsService .handle_functions_error (error )
181
181
182
182
def delete (self , task_id : str ) -> None :
183
- """Deletes an enqueued task if it has not yet completed .
183
+ """Deletes an enqueued task if it has not yet started .
184
184
185
185
This action requires `cloudtasks.tasks.delete` IAM permission on the service account.
186
186
@@ -343,52 +343,53 @@ def is_url(cls, url: Any):
343
343
class TaskOptions :
344
344
"""Task Options that can be applied to a Task.
345
345
Args:
346
- schedule_delay_seconds: The duration of delay of the time when the task is scheduled to be
347
- attemptedor retried. This delay is added to the current time. Should only been set if
348
- ``schedeule_time``is not set.
346
+ schedule_delay_seconds: The number of seconds after the current time at which to attempt or
347
+ retry the task. Should only be set if ``schedule_time`` is not set.
349
348
350
349
schedule_time: The time when the task is scheduled to be attempted or retried. Should only
351
- been set if ``schedule_delay_seconds`` is not set.
350
+ be set if ``schedule_delay_seconds`` is not set.
352
351
353
352
dispatch_deadline_seconds: The deadline for requests sent to the worker. If the worker does
354
353
not respond by this deadline then the request is cancelled and the attempt is marked as
355
354
a ``DEADLINE_EXCEEDED`` failure. Cloud Tasks will retry the task according to the
356
355
``RetryConfig``. The default is 10 minutes. The deadline must be in the range of 15
357
356
seconds and 30 minutes (1800 seconds).
358
357
359
- task_id: The ID to use for the enqueued event . If not provided, one will be automatically
358
+ task_id: The ID to use for the enqueued task . If not provided, one will be automatically
360
359
generated.
361
360
362
361
If provided, an explicitly specified task ID enables task de-duplication.
363
- Task IDs should be string that contain only letters ([A-Za-z]), numbers ([0-9]),
364
- hyphens (-), or underscores (_) with a maximum length of 500 characters. If a task's
362
+ Task IDs should be strings that contain only letters ([A-Za-z]), numbers ([0-9]),
363
+ hyphens (-), and underscores (_) with a maximum length of 500 characters. If a task's
365
364
ID is identical to that of an existing task or a task that was deleted or executed
366
365
recently then the call will throw an error with code "functions/task-already-exists".
367
366
Another task with the same ID can't be created for ~1hour after the original task was
368
367
deleted or executed.
369
368
370
369
Because there is an extra lookup cost to identify duplicate task IDs, setting ID
371
- significantly increases latency. Using hashed strings for the task ID or for the prefix
372
- of the task ID is recommended. Choosing task IDs that are sequential or have sequential
373
- prefixes, for example using a timestamp, causes an increase in latency and error rates
374
- in all task commands. The infrastructure relies on an approximately uniform distribution
375
- of task IDs to store and serve tasks efficiently.
370
+ significantly increases latency.
371
+
372
+ Also, note that the infrastructure relies on an approximately uniform distribution
373
+ of task IDs to store and serve tasks efficiently. For this reason, using hashed strings
374
+ for the task ID or for the prefix of the task ID is recommended. Choosing task IDs that
375
+ are sequential or have sequential prefixes, for example using a timestamp, causes an
376
+ increase in latency and error rates in all task commands.
376
377
377
378
"Push IDs" from the Firebase Realtime Database make poor IDs because they are based on
378
379
timestamps and will cause contention (slowdowns) in your task queue. Reversed push IDs
379
- however form a perfect distribution and are an ideal key. To reverse a string in python
380
+ however form a perfect distribution and are an ideal key. To reverse a string in Python
380
381
use ``reversedString = someString[::-1]``
381
382
382
383
headers: HTTP request headers to include in the request to the task queue function. These
383
384
headers represent a subset of the headers that will accompany the task's HTTP request.
384
- Some HTTP request headers will be ignored or replaced, e.g. Authorization, Host,
385
- Content-Length, User-Agent etc. cannot be overridden.
385
+ Some HTTP request headers will be ignored or replaced: ` Authorization`, ` Host` ,
386
+ ` Content-Length`, ` User-Agent` and others cannot be overridden.
386
387
387
- By default, Content-Type is set to 'application/json'.
388
+ ` Content-Type` is always set to 'application/json'.
388
389
389
390
The size of the headers must be less than 80KB.
390
391
391
- uri: The full URL path that the request will be sent to. Must be a valid RFC3986 https or
392
+ uri: The full URL that the request will be sent to. Must be a valid RFC3986 https or
392
393
http URL.
393
394
"""
394
395
schedule_delay_seconds : Optional [int ] = None
@@ -402,12 +403,13 @@ class TaskOptions:
402
403
class Task :
403
404
"""Contains the relevant fields for enqueueing tasks that trigger Cloud Functions.
404
405
405
- This is a limited subset of Cloud Functions Task:
406
+ This is a limited subset of the Cloud Functions `Task` resource. See the following
407
+ page for definitions of this class's properties:
406
408
https://cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#resource:-task
407
409
408
410
Args:
409
411
httpRequest: The request to be made by the task worker.
410
- name: The url path to identify the function .
412
+ name: The name of the function. See the Cloud docs for the format of this property .
411
413
schedule_time: The time when the task is scheduled to be attempted or retried.
412
414
dispatch_deadline: The deadline for requests sent to the worker.
413
415
"""
0 commit comments