@@ -36,6 +36,12 @@ export type FunctionState = "ACTIVE" | "FAILED" | "DEPLOYING" | "DELETING" | "UN
3636// Values allowed for the operator field in EventFilter
3737export type EventFilterOperator = "match-path-pattern" ;
3838
39+ // Values allowed for the event trigger retry policy in case of a function's execution failure.
40+ export type RetryPolicy =
41+ | "RETRY_POLICY_UNSPECIFIED"
42+ | "RETRY_POLICY_DO_NOT_RETRY"
43+ | "RETRY_POLICY_RETRY" ;
44+
3945/** Settings for building a container out of the customer source. */
4046export interface BuildConfig {
4147 runtime : runtimes . Runtime ;
@@ -140,6 +146,8 @@ export interface EventTrigger {
140146 // to the defualt compute service account.
141147 serviceAccountEmail ?: string ;
142148
149+ retryPolicy ?: RetryPolicy ;
150+
143151 // The name of the channel associated with the trigger in
144152 // `projects/{project}/locations/{location}/channels/{channel}` format.
145153 channel ?: string ;
@@ -542,6 +550,7 @@ export function functionFromEndpoint(endpoint: backend.Endpoint): InputCloudFunc
542550 if ( backend . isEventTriggered ( endpoint ) ) {
543551 gcfFunction . eventTrigger = {
544552 eventType : endpoint . eventTrigger . eventType ,
553+ retryPolicy : "RETRY_POLICY_UNSPECIFIED" ,
545554 } ;
546555 if ( gcfFunction . eventTrigger . eventType === PUBSUB_PUBLISH_EVENT ) {
547556 if ( ! endpoint . eventTrigger . eventFilters ?. topic ) {
@@ -579,9 +588,10 @@ export function functionFromEndpoint(endpoint: backend.Endpoint): InputCloudFunc
579588 ) ;
580589 proto . copyIfPresent ( gcfFunction . eventTrigger , endpoint . eventTrigger , "channel" ) ;
581590
582- if ( endpoint . eventTrigger . retry ) {
583- logger . warn ( "Cannot set a retry policy on Cloud Function" , endpoint . id ) ;
584- }
591+ endpoint . eventTrigger . retry
592+ ? ( gcfFunction . eventTrigger . retryPolicy = "RETRY_POLICY_RETRY" )
593+ : ( gcfFunction . eventTrigger ! . retryPolicy = "RETRY_POLICY_DO_NOT_RETRY" ) ;
594+
585595 // By default, Functions Framework in GCFv2 opts to downcast incoming cloudevent messages to legacy formats.
586596 // Since Firebase Functions SDK expects messages in cloudevent format, we set FUNCTION_SIGNATURE_TYPE to tell
587597 // Functions Framework to disable downcast before passing the cloudevent message to function handler.
@@ -665,7 +675,7 @@ export function endpointFromFunction(gcfFunction: OutputCloudFunction): backend.
665675 trigger = {
666676 eventTrigger : {
667677 eventType : gcfFunction . eventTrigger . eventType ,
668- retry : false ,
678+ retry : gcfFunction . eventTrigger . retryPolicy === "RETRY_POLICY_RETRY" ? true : false ,
669679 } ,
670680 } ;
671681 if ( Object . keys ( eventFilters ) . length ) {
0 commit comments