Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow disabling smart retries [gh-943] #944

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/cli/src/constructs/check-group.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
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 @@ -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
Loading