@@ -66,6 +66,23 @@ function assertRuntimeOptionsValid(runtimeOptions: RuntimeOptions): boolean {
66
66
`TimeoutSeconds must be between 0 and ${ MAX_TIMEOUT_SECONDS } `
67
67
) ;
68
68
}
69
+ if ( runtimeOptions . failurePolicy !== undefined ) {
70
+ if (
71
+ _ . isBoolean ( runtimeOptions . failurePolicy ) === false &&
72
+ _ . isObjectLike ( runtimeOptions . failurePolicy ) === false
73
+ ) {
74
+ throw new Error ( `failurePolicy must be a boolean or an object.` ) ;
75
+ }
76
+
77
+ if ( typeof runtimeOptions . failurePolicy === 'object' ) {
78
+ if (
79
+ _ . isObjectLike ( runtimeOptions . failurePolicy . retry ) === false ||
80
+ _ . isEmpty ( runtimeOptions . failurePolicy . retry ) === false
81
+ ) {
82
+ throw new Error ( 'failurePolicy.retry must be an empty object.' ) ;
83
+ }
84
+ }
85
+ }
69
86
return true ;
70
87
}
71
88
@@ -100,10 +117,14 @@ export function region(
100
117
/**
101
118
* Configure runtime options for the function.
102
119
* @param runtimeOptions Object with three optional fields:
103
- * 1. memory: amount of memory to allocate to the function, possible values
104
- * are: '128MB', '256MB', '512MB', '1GB', and '2GB'.
105
- * 2. timeoutSeconds: timeout for the function in seconds, possible values are
106
- * 0 to 540.
120
+ * 1. failurePolicy: failure policy of the function, with boolean `true` being
121
+ * equivalent to providing an empty retry object.
122
+ * 2. memory: amount of memory to allocate to the function, with possible
123
+ * values being '128MB', '256MB', '512MB', '1GB', and '2GB'.
124
+ * 3. timeoutSeconds: timeout for the function in seconds, with possible
125
+ * values being 0 to 540.
126
+ *
127
+ * Value must not be null.
107
128
*/
108
129
export function runWith ( runtimeOptions : RuntimeOptions ) : FunctionBuilder {
109
130
if ( assertRuntimeOptionsValid ( runtimeOptions ) ) {
@@ -134,10 +155,14 @@ export class FunctionBuilder {
134
155
/**
135
156
* Configure runtime options for the function.
136
157
* @param runtimeOptions Object with three optional fields:
137
- * 1. memory: amount of memory to allocate to the function, possible values
138
- * are: '128MB', '256MB', '512MB', '1GB', and '2GB'.
139
- * 2. timeoutSeconds: timeout for the function in seconds, possible values are
140
- * 0 to 540.
158
+ * 1. failurePolicy: failure policy of the function, with boolean `true` being
159
+ * equivalent to providing an empty retry object.
160
+ * 2. memory: amount of memory to allocate to the function, with possible
161
+ * values being '128MB', '256MB', '512MB', '1GB', and '2GB'.
162
+ * 3. timeoutSeconds: timeout for the function in seconds, with possible
163
+ * values being 0 to 540.
164
+ *
165
+ * Value must not be null.
141
166
*/
142
167
runWith ( runtimeOptions : RuntimeOptions ) : FunctionBuilder {
143
168
if ( assertRuntimeOptionsValid ( runtimeOptions ) ) {
@@ -147,6 +172,12 @@ export class FunctionBuilder {
147
172
}
148
173
149
174
get https ( ) {
175
+ if ( this . options . failurePolicy !== undefined ) {
176
+ console . warn (
177
+ 'RuntimeOptions.failurePolicy is not supported in https functions.'
178
+ ) ;
179
+ }
180
+
150
181
return {
151
182
/**
152
183
* Handle HTTP requests.
0 commit comments