Skip to content

Commit 0482294

Browse files
committed
fix: TW requested changes
1 parent 998ada6 commit 0482294

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

firebase_admin/functions.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ def task_queue(
6262
extension_id: Optional[str] = None,
6363
app: Optional[App] = None
6464
) -> 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.
6666
6767
The function name can be either:
68-
1) A fully qualified function resource name:
68+
1. A fully qualified function resource name:
6969
`projects/{project-id}/locations/{location-id}/functions/{function-name}`
7070
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
7272
the runtime project ID is used:
7373
`locations/{location-id}/functions/{function-name}`
7474
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
7676
default location, `us-central1`, is used:
7777
`{function-name}`
7878
@@ -180,7 +180,7 @@ def enqueue(self, task_data: Any, opts: Optional[TaskOptions] = None) -> str:
180180
raise _FunctionsService.handle_functions_error(error)
181181

182182
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.
184184
185185
This action requires `cloudtasks.tasks.delete` IAM permission on the service account.
186186
@@ -343,52 +343,53 @@ def is_url(cls, url: Any):
343343
class TaskOptions:
344344
"""Task Options that can be applied to a Task.
345345
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.
349348
350349
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.
352351
353352
dispatch_deadline_seconds: The deadline for requests sent to the worker. If the worker does
354353
not respond by this deadline then the request is cancelled and the attempt is marked as
355354
a ``DEADLINE_EXCEEDED`` failure. Cloud Tasks will retry the task according to the
356355
``RetryConfig``. The default is 10 minutes. The deadline must be in the range of 15
357356
seconds and 30 minutes (1800 seconds).
358357
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
360359
generated.
361360
362361
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
365364
ID is identical to that of an existing task or a task that was deleted or executed
366365
recently then the call will throw an error with code "functions/task-already-exists".
367366
Another task with the same ID can't be created for ~1hour after the original task was
368367
deleted or executed.
369368
370369
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.
376377
377378
"Push IDs" from the Firebase Realtime Database make poor IDs because they are based on
378379
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
380381
use ``reversedString = someString[::-1]``
381382
382383
headers: HTTP request headers to include in the request to the task queue function. These
383384
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.
386387
387-
By default, Content-Type is set to 'application/json'.
388+
`Content-Type` is always set to 'application/json'.
388389
389390
The size of the headers must be less than 80KB.
390391
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
392393
http URL.
393394
"""
394395
schedule_delay_seconds: Optional[int] = None
@@ -402,12 +403,13 @@ class TaskOptions:
402403
class Task:
403404
"""Contains the relevant fields for enqueueing tasks that trigger Cloud Functions.
404405
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:
406408
https://cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#resource:-task
407409
408410
Args:
409411
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.
411413
schedule_time: The time when the task is scheduled to be attempted or retried.
412414
dispatch_deadline: The deadline for requests sent to the worker.
413415
"""

0 commit comments

Comments
 (0)