@@ -66,6 +66,23 @@ function assertRuntimeOptionsValid(runtimeOptions: RuntimeOptions): boolean {
6666 `TimeoutSeconds must be between 0 and ${ MAX_TIMEOUT_SECONDS } `
6767 ) ;
6868 }
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+ }
6986 return true ;
7087}
7188
@@ -100,10 +117,14 @@ export function region(
100117/**
101118 * Configure runtime options for the function.
102119 * @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.
107128 */
108129export function runWith ( runtimeOptions : RuntimeOptions ) : FunctionBuilder {
109130 if ( assertRuntimeOptionsValid ( runtimeOptions ) ) {
@@ -134,10 +155,14 @@ export class FunctionBuilder {
134155 /**
135156 * Configure runtime options for the function.
136157 * @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.
141166 */
142167 runWith ( runtimeOptions : RuntimeOptions ) : FunctionBuilder {
143168 if ( assertRuntimeOptionsValid ( runtimeOptions ) ) {
@@ -147,6 +172,12 @@ export class FunctionBuilder {
147172 }
148173
149174 get https ( ) {
175+ if ( this . options . failurePolicy !== undefined ) {
176+ console . warn (
177+ 'RuntimeOptions.failurePolicy is not supported in https functions.'
178+ ) ;
179+ }
180+
150181 return {
151182 /**
152183 * Handle HTTP requests.
0 commit comments