Skip to content

Commit

Permalink
fix: allow disabling smart retries [gh-943] (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
clample committed Mar 25, 2024
1 parent ec3a946 commit 4fcc819
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
11 changes: 9 additions & 2 deletions packages/cli/src/constructs/check-group.ts
Expand Up @@ -282,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 @@ -295,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
11 changes: 9 additions & 2 deletions packages/cli/src/constructs/check.ts
Expand Up @@ -222,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 @@ -235,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
9 changes: 8 additions & 1 deletion packages/cli/src/constructs/retry-strategy.ts
@@ -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 @@ -55,6 +55,13 @@ export class RetryStrategyBuilder {
return RetryStrategyBuilder.retryStrategy('EXPONENTIAL', options)
}

/**
* No retries are performed.
*/
static noRetries (): RetryStrategy {
return RetryStrategyBuilder.retryStrategy('NO_RETRIES')
}

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

0 comments on commit 4fcc819

Please sign in to comment.