@@ -6,27 +6,52 @@ export type RetryStrategyResource = RetryStrategy
6
6
export function valueForRetryStrategy ( genfile : GeneratedFile , strategy ?: RetryStrategyResource | null ) : Value {
7
7
genfile . namedImport ( 'RetryStrategyBuilder' , 'checkly/constructs' )
8
8
9
- function buildCommonOptions (
9
+ function buildBaseBackoffSecondsOption (
10
10
options : RetryStrategyOptions ,
11
11
builder : ObjectValueBuilder ,
12
12
) : void {
13
13
if ( options . baseBackoffSeconds ) {
14
14
builder . number ( 'baseBackoffSeconds' , options . baseBackoffSeconds )
15
15
}
16
+ }
16
17
18
+ function buildMaxRetriesOption (
19
+ options : RetryStrategyOptions ,
20
+ builder : ObjectValueBuilder ,
21
+ ) : void {
17
22
if ( options . maxRetries ) {
18
23
builder . number ( 'maxRetries' , options . maxRetries )
19
24
}
25
+ }
20
26
27
+ function buildMaxDurationSecondsOption (
28
+ options : RetryStrategyOptions ,
29
+ builder : ObjectValueBuilder ,
30
+ ) : void {
21
31
if ( options . maxDurationSeconds ) {
22
32
builder . number ( 'maxDurationSeconds' , options . maxDurationSeconds )
23
33
}
34
+ }
24
35
36
+ function buildSameRegionOption (
37
+ options : RetryStrategyOptions ,
38
+ builder : ObjectValueBuilder ,
39
+ ) : void {
25
40
if ( options . sameRegion !== undefined ) {
26
41
builder . boolean ( 'sameRegion' , options . sameRegion )
27
42
}
28
43
}
29
44
45
+ function buildCommonOptions (
46
+ options : RetryStrategyOptions ,
47
+ builder : ObjectValueBuilder ,
48
+ ) : void {
49
+ buildBaseBackoffSecondsOption ( options , builder )
50
+ buildMaxRetriesOption ( options , builder )
51
+ buildMaxDurationSecondsOption ( options , builder )
52
+ buildSameRegionOption ( options , builder )
53
+ }
54
+
30
55
if ( strategy === null || strategy === undefined ) {
31
56
return expr ( ident ( 'RetryStrategyBuilder' ) , builder => {
32
57
builder . member ( ident ( 'noRetries' ) )
@@ -64,6 +89,16 @@ export function valueForRetryStrategy (genfile: GeneratedFile, strategy?: RetryS
64
89
} )
65
90
} )
66
91
} )
92
+ case 'SINGLE' :
93
+ return expr ( ident ( 'RetryStrategyBuilder' ) , builder => {
94
+ builder . member ( ident ( 'singleRetry' ) )
95
+ builder . call ( builder => {
96
+ builder . object ( builder => {
97
+ buildBaseBackoffSecondsOption ( strategy , builder )
98
+ buildSameRegionOption ( strategy , builder )
99
+ } )
100
+ } )
101
+ } )
67
102
case 'NO_RETRIES' :
68
103
return expr ( ident ( 'RetryStrategyBuilder' ) , builder => {
69
104
builder . member ( ident ( 'noRetries' ) )
0 commit comments