@@ -36,6 +36,12 @@ export type FunctionState = "ACTIVE" | "FAILED" | "DEPLOYING" | "DELETING" | "UN
36
36
// Values allowed for the operator field in EventFilter
37
37
export type EventFilterOperator = "match-path-pattern" ;
38
38
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
+
39
45
/** Settings for building a container out of the customer source. */
40
46
export interface BuildConfig {
41
47
runtime : runtimes . Runtime ;
@@ -140,6 +146,8 @@ export interface EventTrigger {
140
146
// to the defualt compute service account.
141
147
serviceAccountEmail ?: string ;
142
148
149
+ retryPolicy ?: RetryPolicy ;
150
+
143
151
// The name of the channel associated with the trigger in
144
152
// `projects/{project}/locations/{location}/channels/{channel}` format.
145
153
channel ?: string ;
@@ -542,6 +550,7 @@ export function functionFromEndpoint(endpoint: backend.Endpoint): InputCloudFunc
542
550
if ( backend . isEventTriggered ( endpoint ) ) {
543
551
gcfFunction . eventTrigger = {
544
552
eventType : endpoint . eventTrigger . eventType ,
553
+ retryPolicy : "RETRY_POLICY_UNSPECIFIED" ,
545
554
} ;
546
555
if ( gcfFunction . eventTrigger . eventType === PUBSUB_PUBLISH_EVENT ) {
547
556
if ( ! endpoint . eventTrigger . eventFilters ?. topic ) {
@@ -579,9 +588,10 @@ export function functionFromEndpoint(endpoint: backend.Endpoint): InputCloudFunc
579
588
) ;
580
589
proto . copyIfPresent ( gcfFunction . eventTrigger , endpoint . eventTrigger , "channel" ) ;
581
590
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
+
585
595
// By default, Functions Framework in GCFv2 opts to downcast incoming cloudevent messages to legacy formats.
586
596
// Since Firebase Functions SDK expects messages in cloudevent format, we set FUNCTION_SIGNATURE_TYPE to tell
587
597
// Functions Framework to disable downcast before passing the cloudevent message to function handler.
@@ -665,7 +675,7 @@ export function endpointFromFunction(gcfFunction: OutputCloudFunction): backend.
665
675
trigger = {
666
676
eventTrigger : {
667
677
eventType : gcfFunction . eventTrigger . eventType ,
668
- retry : false ,
678
+ retry : gcfFunction . eventTrigger . retryPolicy === "RETRY_POLICY_RETRY" ? true : false ,
669
679
} ,
670
680
} ;
671
681
if ( Object . keys ( eventFilters ) . length ) {
0 commit comments