-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into remove-repo-url-from-example-projects
- Loading branch information
Showing
20 changed files
with
235 additions
and
22 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
examples/advanced-project-js/src/__checks__/heartbeat.check.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { HeartbeatCheck } = require('checkly/constructs') | ||
|
||
// Heartbeat checks allow you to monitor jobs or recurring tasks. | ||
// This feature is only available on paid plans. | ||
// Upgrade your plan to start using it https://app.checklyhq.com/new-billing | ||
// If you're already on a paid plan, uncomment the following lines to create a heartbeat check. | ||
|
||
/* new HeartbeatCheck('heartbeat-check-1', { | ||
name: 'Send weekly newsletter job', | ||
period: 1, | ||
periodUnit: 'hours', | ||
grace: 30, | ||
graceUnit: 'minutes', | ||
}) | ||
*/ | ||
|
16 changes: 16 additions & 0 deletions
16
examples/advanced-project/src/__checks__/heartbeat.check.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { HeartbeatCheck } from 'checkly/constructs' | ||
|
||
// Heartbeat checks allow you to monitor jobs or recurring tasks. | ||
// This feature is only available on paid plans. | ||
// Upgrade your plan to start using it https://app.checklyhq.com/new-billing | ||
// If you're already on a paid plan, uncomment the following lines to create a heartbeat check. | ||
|
||
/* new HeartbeatCheck('heartbeat-check-1', { | ||
name: 'Send weekly newsletter job', | ||
period: 1, | ||
periodUnit: 'hours', | ||
grace: 30, | ||
graceUnit: 'minutes', | ||
}) | ||
*/ | ||
|
16 changes: 16 additions & 0 deletions
16
examples/boilerplate-project-js/__checks__/heartbeat.check.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { HeartbeatCheck } = require('checkly/constructs') | ||
|
||
// Heartbeat checks allow you to monitor jobs or recurring tasks. | ||
// This feature is only available on paid plans. | ||
// Upgrade your plan to start using it https://app.checklyhq.com/new-billing | ||
// If you're already on a paid plan, uncomment the following lines to create a heartbeat check. | ||
|
||
/* new HeartbeatCheck('heartbeat-check-1', { | ||
name: 'Send weekly newsletter job', | ||
period: 1, | ||
periodUnit: 'hours', | ||
grace: 30, | ||
graceUnit: 'minutes', | ||
}) | ||
*/ | ||
|
17 changes: 12 additions & 5 deletions
17
examples/boilerplate-project/__checks__/heartbeat.check.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import { HeartbeatCheck } from 'checkly/constructs' | ||
|
||
new HeartbeatCheck('heartbeat-check-1', { | ||
// Heartbeat checks allow you to monitor jobs or recurring tasks. | ||
// This feature is only available on paid plans. | ||
// Upgrade your plan to start using it https://app.checklyhq.com/new-billing | ||
// If you're already on a paid plan, uncomment the following lines to create a heartbeat check. | ||
|
||
/* new HeartbeatCheck('heartbeat-check-1', { | ||
name: 'Send weekly newsletter job', | ||
period: 7, | ||
periodUnit: 'days', | ||
grace: 2, | ||
graceUnit: 'hours', | ||
period: 1, | ||
periodUnit: 'hours', | ||
grace: 30, | ||
graceUnit: 'minutes', | ||
}) | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
export type RetryStrategyType = 'LINEAR' | 'EXPONENTIAL' | 'FIXED' | ||
|
||
export interface RetryStrategy { | ||
type: RetryStrategyType, | ||
/** | ||
* The number of seconds to wait before the first retry attempt. | ||
*/ | ||
baseBackoffSeconds?: number, | ||
/** | ||
* The maximum number of attempts to retry the check. Value must be between 1 and 10. | ||
*/ | ||
maxAttempts?: number, | ||
/** | ||
* The total amount of time to continue retrying the check (maximum 600 seconds). | ||
*/ | ||
maxDurationSeconds?: number, | ||
/** | ||
* Whether retries should be run in the same region as the initial check run. | ||
*/ | ||
sameRegion?: boolean, | ||
} | ||
|
||
export type RetryStrategyOptions = Pick<RetryStrategy, 'baseBackoffSeconds' | 'maxAttempts' | 'maxDurationSeconds' | 'sameRegion'> | ||
|
||
export class RetryStrategyBuilder { | ||
private static readonly DEFAULT_BASE_BACKOFF_SECONDS = 60 | ||
private static readonly DEFAULT_MAX_ATTEMPTS = 2 | ||
private static readonly DEFAULT_MAX_DURATION_SECONDS = 60 * 10 | ||
private static readonly DEFAULT_SAME_REGION = false | ||
|
||
/** | ||
* Each retry is run with the same backoff between attempts. | ||
*/ | ||
static fixedStrategy (options: RetryStrategyOptions): RetryStrategy { | ||
return RetryStrategyBuilder.retryStrategy('FIXED', options) | ||
} | ||
|
||
/** | ||
* The delay between retries increases linearly | ||
* | ||
* The delay between retries is calculated using `baseBackoffSeconds * attempt`. | ||
* For example, retries will be run with a backoff of 10s, 20s, 30s, and so on. | ||
*/ | ||
static linearStrategy (options: RetryStrategyOptions): RetryStrategy { | ||
return RetryStrategyBuilder.retryStrategy('LINEAR', options) | ||
} | ||
|
||
/** | ||
* The delay between retries increases exponentially | ||
* | ||
* The delay between retries is calculated using `baseBackoffSeconds ^ attempt`. | ||
* For example, retries will be run with a backoff of 10s, 100s, 1000s, and so on. | ||
*/ | ||
static exponentialStrategy (options: RetryStrategyOptions): RetryStrategy { | ||
return RetryStrategyBuilder.retryStrategy('EXPONENTIAL', options) | ||
} | ||
|
||
private static retryStrategy (type: RetryStrategyType, options: RetryStrategyOptions): RetryStrategy { | ||
return { | ||
type, | ||
baseBackoffSeconds: options.baseBackoffSeconds ?? RetryStrategyBuilder.DEFAULT_BASE_BACKOFF_SECONDS, | ||
maxAttempts: options.maxAttempts ?? RetryStrategyBuilder.DEFAULT_MAX_ATTEMPTS, | ||
maxDurationSeconds: options.maxDurationSeconds ?? RetryStrategyBuilder.DEFAULT_MAX_DURATION_SECONDS, | ||
sameRegion: options.sameRegion ?? RetryStrategyBuilder.DEFAULT_SAME_REGION, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.