Skip to content

Commit

Permalink
Add NO_RETRIES type
Browse files Browse the repository at this point in the history
  • Loading branch information
clample committed Mar 25, 2024
1 parent b5e2a1a commit 34dcc6c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
21 changes: 12 additions & 9 deletions packages/cli/src/constructs/check-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export interface CheckGroupProps {
/**
* Sets a retry policy for the group. Use RetryStrategyBuilder to create a retry policy.
*/
retryStrategy?: RetryStrategy | null
retryStrategy?: RetryStrategy
/**
* Determines whether the checks in the group should run on all selected locations in parallel or round-robin.
* See https://www.checklyhq.com/docs/monitoring/global-locations/ to learn more about scheduling strategies.
Expand Down Expand Up @@ -143,7 +143,7 @@ export class CheckGroup extends Construct {
apiCheckDefaults: ApiCheckDefaultConfig
browserChecks?: BrowserCheckConfig
multiStepChecks?: MultiStepCheckConfig
retryStrategy?: RetryStrategy | null
retryStrategy?: RetryStrategy
runParallel?: boolean
alertSettings?: AlertEscalation
useGlobalAlertSettings?: boolean
Expand All @@ -163,6 +163,7 @@ export class CheckGroup extends Construct {
this.name = props.name
this.activated = props.activated
this.muted = props.muted
this.doubleCheck = props.doubleCheck
this.tags = props.tags
this.runtimeId = props.runtimeId
this.locations = props.locations
Expand All @@ -184,11 +185,6 @@ export class CheckGroup extends Construct {
this.alertChannels = props.alertChannels ?? []
this.localSetupScript = props.localSetupScript
this.localTearDownScript = props.localTearDownScript
// When `retryStrategy: null` and `doubleCheck: undefined`, we want to let the user disable all retries.
// The backend has a Joi default of `doubleCheck: true`, though, so we need special handling for this case.
this.doubleCheck = props.doubleCheck === undefined && props.retryStrategy === null
? false
: props.doubleCheck
this.retryStrategy = props.retryStrategy
this.runParallel = props.runParallel
// `browserChecks` is not a CheckGroup resource property. Not present in synthesize()
Expand Down Expand Up @@ -286,7 +282,6 @@ export class CheckGroup extends Construct {
name: this.name,
activated: this.activated,
muted: this.muted,
doubleCheck: this.doubleCheck,
tags: this.tags,
locations: this.locations,
runtimeId: this.runtimeId,
Expand All @@ -299,7 +294,15 @@ export class CheckGroup extends Construct {
localTearDownScript: this.localTearDownScript,
apiCheckDefaults: this.apiCheckDefaults,
environmentVariables: this.environmentVariables,
retryStrategy: this.retryStrategy,
// The backend doesn't actually support the `NO_RETRIES` type, it uses `null` instead.
retryStrategy: this.retryStrategy?.type === 'NO_RETRIES'
? null
: this.retryStrategy,
// When `retryStrategy: NO_RETRIES` and `doubleCheck: undefined`, we want to let the user disable all retries.
// The backend has a Joi default of `doubleCheck: true`, though, so we need special handling for this case.
doubleCheck: this.doubleCheck === undefined && this.retryStrategy?.type === 'NO_RETRIES'
? false
: this.doubleCheck,
runParallel: this.runParallel,
alertSettings: this.alertSettings,
useGlobalAlertSettings: this.useGlobalAlertSettings,
Expand Down
21 changes: 12 additions & 9 deletions packages/cli/src/constructs/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export interface CheckProps {
/**
* Sets a retry policy for the check. Use RetryStrategyBuilder to create a retry policy.
*/
retryStrategy?: RetryStrategy | null
retryStrategy?: RetryStrategy
/**
* Determines whether the check should run on all selected locations in parallel or round-robin.
* See https://www.checklyhq.com/docs/monitoring/global-locations/ to learn more about scheduling strategies.
Expand All @@ -117,7 +117,7 @@ export abstract class Check extends Construct {
groupId?: Ref
alertChannels?: Array<AlertChannel>
testOnly?: boolean
retryStrategy?: RetryStrategy | null
retryStrategy?: RetryStrategy
alertSettings?: AlertEscalation
useGlobalAlertSettings?: boolean
runParallel?: boolean
Expand All @@ -135,6 +135,7 @@ export abstract class Check extends Construct {
this.name = props.name
this.activated = props.activated
this.muted = props.muted
this.doubleCheck = props.doubleCheck
this.shouldFail = props.shouldFail
this.locations = props.locations
this.privateLocations = props.privateLocations
Expand All @@ -155,11 +156,6 @@ export abstract class Check extends Construct {
// alertSettings, useGlobalAlertSettings, groupId, groupOrder

this.testOnly = props.testOnly ?? false
// When `retryStrategy: null` and `doubleCheck: undefined`, we want to let the user disable all retries.
// The backend has a Joi default of `doubleCheck: true`, though, so we need special handling for this case.
this.doubleCheck = props.doubleCheck === undefined && props.retryStrategy === null
? false
: props.doubleCheck
this.retryStrategy = props.retryStrategy
this.alertSettings = props.alertEscalationPolicy
this.useGlobalAlertSettings = !this.alertSettings
Expand Down Expand Up @@ -226,7 +222,6 @@ export abstract class Check extends Construct {
name: this.name,
activated: this.activated,
muted: this.muted,
doubleCheck: this.doubleCheck,
shouldFail: this.shouldFail,
runtimeId: this.runtimeId,
locations: this.locations,
Expand All @@ -239,7 +234,15 @@ export abstract class Check extends Construct {
frequencyOffset: this.frequencyOffset,
groupId: this.groupId,
environmentVariables: this.environmentVariables,
retryStrategy: this.retryStrategy,
// The backend doesn't actually support the `NO_RETRIES` type, it uses `null` instead.
retryStrategy: this.retryStrategy?.type === 'NO_RETRIES'
? null
: this.retryStrategy,
// When `retryStrategy: NO_RETRIES` and `doubleCheck: undefined`, we want to let the user disable all retries.
// The backend has a Joi default of `doubleCheck: true`, though, so we need special handling for this case.
doubleCheck: this.doubleCheck === undefined && this.retryStrategy?.type === 'NO_RETRIES'
? false
: this.doubleCheck,
alertSettings: this.alertSettings,
useGlobalAlertSettings: this.useGlobalAlertSettings,
runParallel: this.runParallel,
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/constructs/retry-strategy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type RetryStrategyType = 'LINEAR' | 'EXPONENTIAL' | 'FIXED'
export type RetryStrategyType = 'LINEAR' | 'EXPONENTIAL' | 'FIXED' | 'NO_RETRIES'

export interface RetryStrategy {
type: RetryStrategyType,
Expand Down Expand Up @@ -58,8 +58,8 @@ export class RetryStrategyBuilder {
/**
* No retries are performed.
*/
static noRetries (): null {
return null
static noRetries (): RetryStrategy {
return RetryStrategyBuilder.retryStrategy('NO_RETRIES')
}

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

0 comments on commit 34dcc6c

Please sign in to comment.