-
Notifications
You must be signed in to change notification settings - Fork 417
Expand file tree
/
Copy pathfunctions-api.ts
More file actions
119 lines (109 loc) · 4.13 KB
/
Copy pathfunctions-api.ts
File metadata and controls
119 lines (109 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*!
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Interface representing task options with delayed delivery.
*/
export interface DelayDelivery {
/**
* The duration of delay of the time when the task is scheduled to be attempted or retried.
* This delay is added to the current time.
*/
scheduleDelaySeconds?: number;
/** @alpha */
scheduleTime?: never;
}
/**
* Interface representing task options with absolute delivery.
*/
export interface AbsoluteDelivery {
/**
* The time when the task is scheduled to be attempted or retried.
*/
scheduleTime?: Date;
/** @alpha */
scheduleDelaySeconds?: never;
}
/**
* Type representing delivery schedule options.
* `DeliverySchedule` is a union type of {@link DelayDelivery} and {@link AbsoluteDelivery} types.
*/
export type DeliverySchedule = DelayDelivery | AbsoluteDelivery
/**
* Type representing task options.
*/
export type TaskOptions = DeliverySchedule & TaskOptionsExperimental & {
/**
* 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 DEADLINE_EXCEEDED failure.
* Cloud Tasks will retry the task according to the `RetryConfig`.
* The default is 10 minutes. The deadline must be in the range of 15 seconds and 30 minutes.
*/
dispatchDeadlineSeconds?: number;
/**
* The ID to use for the enqueued event.
* If not provided, one will be automatically generated.
* If provided, an explicitly specified task ID enables task de-duplication. If a task's ID is
* identical to that of an existing task or a task that was deleted or executed recently then
* the call will throw an error with code "functions/task-already-exists". Another task with
* the same ID can't be created for ~1hour after the original task was deleted or executed.
*
* Because there is an extra lookup cost to identify duplicate task IDs, setting ID
* significantly increases latency. Using hashed strings for the task ID or for the prefix of
* the task ID is recommended. Choosing task IDs that are sequential or have sequential
* prefixes, for example using a timestamp, causes an increase in latency and error rates in
* all task commands. The infrastructure relies on an approximately uniform distribution of
* task IDs to store and serve tasks efficiently.
*
* "Push IDs" from the Firebase Realtime Database make poor IDs because they are based on
* timestamps and will cause contention (slowdowns) in your task queue. Reversed push IDs
* however form a perfect distribution and are an ideal key. To reverse a string in
* javascript use `someString.split("").reverse().join("")`
*/
id?: string;
/**
* HTTP request headers to include in the request to the task queue function.
* 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, e.g. Authorization, Host, Content-Length,
* User-Agent etc. cannot be overridden.
*
* By default, Content-Type is set to 'application/json'.
*
* The size of the headers must be less than 80KB.
*/
headers?: Record<string, string>;
}
/**
* Type representing experimental (beta) task options.
*/
export interface TaskOptionsExperimental {
/**
* The full URL path that the request will be sent to. Must be a valid URL.
* @beta
*/
uri?: string;
}
/**
* Type representing the scope of a function in a task queue.
*/
export type FunctionScope = {
scope: 'current';
} | {
scope: 'global';
} | {
scope: 'extension';
instance: string;
};