-
Notifications
You must be signed in to change notification settings - Fork 203
/
function-configuration.ts
168 lines (147 loc) · 3.52 KB
/
function-configuration.ts
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/**
* List of all regions supported by Cloud Functions.
*/
export const SUPPORTED_REGIONS = [
'us-central1',
'us-east1',
'us-east4',
'us-west2',
'us-west3',
'us-west4',
'europe-central2',
'europe-west1',
'europe-west2',
'europe-west3',
'europe-west6',
'asia-east1',
'asia-east2',
'asia-northeast1',
'asia-northeast2',
'asia-northeast3',
'asia-south1',
'asia-southeast1',
'asia-southeast2',
'northamerica-northeast1',
'southamerica-east1',
'australia-southeast1',
] as const;
/**
* Cloud Functions min timeout value.
*/
export const MIN_TIMEOUT_SECONDS = 0;
/**
* Cloud Functions max timeout value.
*/
export const MAX_TIMEOUT_SECONDS = 540;
/**
* List of available memory options supported by Cloud Functions.
*/
export const VALID_MEMORY_OPTIONS = [
'128MB',
'256MB',
'512MB',
'1GB',
'2GB',
'4GB',
'8GB',
] as const;
/**
* List of available options for VpcConnectorEgressSettings.
*/
export const VPC_EGRESS_SETTINGS_OPTIONS = [
'VPC_CONNECTOR_EGRESS_SETTINGS_UNSPECIFIED',
'PRIVATE_RANGES_ONLY',
'ALL_TRAFFIC',
] as const;
/**
* List of available options for IngressSettings.
*/
export const INGRESS_SETTINGS_OPTIONS = [
'INGRESS_SETTINGS_UNSPECIFIED',
'ALLOW_ALL',
'ALLOW_INTERNAL_ONLY',
'ALLOW_INTERNAL_AND_GCLB',
] as const;
/**
* Scheduler retry options. Applies only to scheduled functions.
*/
export interface ScheduleRetryConfig {
retryCount?: number;
maxRetryDuration?: string;
minBackoffDuration?: string;
maxBackoffDuration?: string;
maxDoublings?: number;
}
/**
* Configuration options for scheduled functions.
*/
export interface Schedule {
schedule: string;
timeZone?: string;
retryConfig?: ScheduleRetryConfig;
}
export interface FailurePolicy {
retry: {};
}
export const DEFAULT_FAILURE_POLICY: FailurePolicy = {
retry: {},
};
export const MAX_NUMBER_USER_LABELS = 58;
export interface RuntimeOptions {
/**
* Which platform should host the backend. Valid options are "gcfv1"
* @hidden
*/
platform?: 'gcfv1';
/**
* Failure policy of the function, with boolean `true` being equivalent to
* providing an empty retry object.
*/
failurePolicy?: FailurePolicy | boolean;
/**
* Amount of memory to allocate to the function.
*/
memory?: typeof VALID_MEMORY_OPTIONS[number];
/**
* Timeout for the function in seconds, possible values are 0 to 540.
*/
timeoutSeconds?: number;
/**
* Min number of actual instances to be running at a given time.
* Instances will be billed for memory allocation and 10% of CPU allocation
* while idle.
*/
minInstances?: number;
/**
* Max number of actual instances allowed to be running in parallel.
*/
maxInstances?: number;
/**
* Connect cloud function to specified VPC connector.
*/
vpcConnector?: string;
/**
* Egress settings for VPC connector.
*/
vpcConnectorEgressSettings?: typeof VPC_EGRESS_SETTINGS_OPTIONS[number];
/**
* Specific service account for the function to run as.
*/
serviceAccount?: 'default' | string;
/**
* Ingress settings which control where this function can be called from.
*/
ingressSettings?: typeof INGRESS_SETTINGS_OPTIONS[number];
/**
* User labels to set on the function.
*/
labels?: Record<string, string>;
/**
* Invoker to set access control on https functions.
*/
invoker?: 'public' | 'private' | string | string[];
}
export interface DeploymentOptions extends RuntimeOptions {
regions?: Array<typeof SUPPORTED_REGIONS[number] | string>;
schedule?: Schedule;
}