Skip to content

Commit 34dcc6c

Browse files
committed
Add NO_RETRIES type
1 parent b5e2a1a commit 34dcc6c

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

Diff for: packages/cli/src/constructs/check-group.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export interface CheckGroupProps {
110110
/**
111111
* Sets a retry policy for the group. Use RetryStrategyBuilder to create a retry policy.
112112
*/
113-
retryStrategy?: RetryStrategy | null
113+
retryStrategy?: RetryStrategy
114114
/**
115115
* Determines whether the checks in the group should run on all selected locations in parallel or round-robin.
116116
* See https://www.checklyhq.com/docs/monitoring/global-locations/ to learn more about scheduling strategies.
@@ -143,7 +143,7 @@ export class CheckGroup extends Construct {
143143
apiCheckDefaults: ApiCheckDefaultConfig
144144
browserChecks?: BrowserCheckConfig
145145
multiStepChecks?: MultiStepCheckConfig
146-
retryStrategy?: RetryStrategy | null
146+
retryStrategy?: RetryStrategy
147147
runParallel?: boolean
148148
alertSettings?: AlertEscalation
149149
useGlobalAlertSettings?: boolean
@@ -163,6 +163,7 @@ export class CheckGroup extends Construct {
163163
this.name = props.name
164164
this.activated = props.activated
165165
this.muted = props.muted
166+
this.doubleCheck = props.doubleCheck
166167
this.tags = props.tags
167168
this.runtimeId = props.runtimeId
168169
this.locations = props.locations
@@ -184,11 +185,6 @@ export class CheckGroup extends Construct {
184185
this.alertChannels = props.alertChannels ?? []
185186
this.localSetupScript = props.localSetupScript
186187
this.localTearDownScript = props.localTearDownScript
187-
// When `retryStrategy: null` and `doubleCheck: undefined`, we want to let the user disable all retries.
188-
// The backend has a Joi default of `doubleCheck: true`, though, so we need special handling for this case.
189-
this.doubleCheck = props.doubleCheck === undefined && props.retryStrategy === null
190-
? false
191-
: props.doubleCheck
192188
this.retryStrategy = props.retryStrategy
193189
this.runParallel = props.runParallel
194190
// `browserChecks` is not a CheckGroup resource property. Not present in synthesize()
@@ -286,7 +282,6 @@ export class CheckGroup extends Construct {
286282
name: this.name,
287283
activated: this.activated,
288284
muted: this.muted,
289-
doubleCheck: this.doubleCheck,
290285
tags: this.tags,
291286
locations: this.locations,
292287
runtimeId: this.runtimeId,
@@ -299,7 +294,15 @@ export class CheckGroup extends Construct {
299294
localTearDownScript: this.localTearDownScript,
300295
apiCheckDefaults: this.apiCheckDefaults,
301296
environmentVariables: this.environmentVariables,
302-
retryStrategy: this.retryStrategy,
297+
// The backend doesn't actually support the `NO_RETRIES` type, it uses `null` instead.
298+
retryStrategy: this.retryStrategy?.type === 'NO_RETRIES'
299+
? null
300+
: this.retryStrategy,
301+
// When `retryStrategy: NO_RETRIES` and `doubleCheck: undefined`, we want to let the user disable all retries.
302+
// The backend has a Joi default of `doubleCheck: true`, though, so we need special handling for this case.
303+
doubleCheck: this.doubleCheck === undefined && this.retryStrategy?.type === 'NO_RETRIES'
304+
? false
305+
: this.doubleCheck,
303306
runParallel: this.runParallel,
304307
alertSettings: this.alertSettings,
305308
useGlobalAlertSettings: this.useGlobalAlertSettings,

Diff for: packages/cli/src/constructs/check.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export interface CheckProps {
9292
/**
9393
* Sets a retry policy for the check. Use RetryStrategyBuilder to create a retry policy.
9494
*/
95-
retryStrategy?: RetryStrategy | null
95+
retryStrategy?: RetryStrategy
9696
/**
9797
* Determines whether the check should run on all selected locations in parallel or round-robin.
9898
* See https://www.checklyhq.com/docs/monitoring/global-locations/ to learn more about scheduling strategies.
@@ -117,7 +117,7 @@ export abstract class Check extends Construct {
117117
groupId?: Ref
118118
alertChannels?: Array<AlertChannel>
119119
testOnly?: boolean
120-
retryStrategy?: RetryStrategy | null
120+
retryStrategy?: RetryStrategy
121121
alertSettings?: AlertEscalation
122122
useGlobalAlertSettings?: boolean
123123
runParallel?: boolean
@@ -135,6 +135,7 @@ export abstract class Check extends Construct {
135135
this.name = props.name
136136
this.activated = props.activated
137137
this.muted = props.muted
138+
this.doubleCheck = props.doubleCheck
138139
this.shouldFail = props.shouldFail
139140
this.locations = props.locations
140141
this.privateLocations = props.privateLocations
@@ -155,11 +156,6 @@ export abstract class Check extends Construct {
155156
// alertSettings, useGlobalAlertSettings, groupId, groupOrder
156157

157158
this.testOnly = props.testOnly ?? false
158-
// When `retryStrategy: null` and `doubleCheck: undefined`, we want to let the user disable all retries.
159-
// The backend has a Joi default of `doubleCheck: true`, though, so we need special handling for this case.
160-
this.doubleCheck = props.doubleCheck === undefined && props.retryStrategy === null
161-
? false
162-
: props.doubleCheck
163159
this.retryStrategy = props.retryStrategy
164160
this.alertSettings = props.alertEscalationPolicy
165161
this.useGlobalAlertSettings = !this.alertSettings
@@ -226,7 +222,6 @@ export abstract class Check extends Construct {
226222
name: this.name,
227223
activated: this.activated,
228224
muted: this.muted,
229-
doubleCheck: this.doubleCheck,
230225
shouldFail: this.shouldFail,
231226
runtimeId: this.runtimeId,
232227
locations: this.locations,
@@ -239,7 +234,15 @@ export abstract class Check extends Construct {
239234
frequencyOffset: this.frequencyOffset,
240235
groupId: this.groupId,
241236
environmentVariables: this.environmentVariables,
242-
retryStrategy: this.retryStrategy,
237+
// The backend doesn't actually support the `NO_RETRIES` type, it uses `null` instead.
238+
retryStrategy: this.retryStrategy?.type === 'NO_RETRIES'
239+
? null
240+
: this.retryStrategy,
241+
// When `retryStrategy: NO_RETRIES` and `doubleCheck: undefined`, we want to let the user disable all retries.
242+
// The backend has a Joi default of `doubleCheck: true`, though, so we need special handling for this case.
243+
doubleCheck: this.doubleCheck === undefined && this.retryStrategy?.type === 'NO_RETRIES'
244+
? false
245+
: this.doubleCheck,
243246
alertSettings: this.alertSettings,
244247
useGlobalAlertSettings: this.useGlobalAlertSettings,
245248
runParallel: this.runParallel,

Diff for: packages/cli/src/constructs/retry-strategy.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type RetryStrategyType = 'LINEAR' | 'EXPONENTIAL' | 'FIXED'
1+
export type RetryStrategyType = 'LINEAR' | 'EXPONENTIAL' | 'FIXED' | 'NO_RETRIES'
22

33
export interface RetryStrategy {
44
type: RetryStrategyType,
@@ -58,8 +58,8 @@ export class RetryStrategyBuilder {
5858
/**
5959
* No retries are performed.
6060
*/
61-
static noRetries (): null {
62-
return null
61+
static noRetries (): RetryStrategy {
62+
return RetryStrategyBuilder.retryStrategy('NO_RETRIES')
6363
}
6464

6565
private static retryStrategy (type: RetryStrategyType, options?: RetryStrategyOptions): RetryStrategy {

0 commit comments

Comments
 (0)