@@ -7,10 +7,16 @@ import { CheckGroupV2 } from './check-group-v2'
77import { Frequency } from './frequency'
88import { IncidentTrigger } from './incident'
99import { PrivateLocation , PrivateLocationRef } from './private-location'
10- import { RetryStrategy } from './retry-strategy'
10+ import { RetryStrategyType , SingleRetryStrategy } from './retry-strategy'
1111import { Check , CheckProps } from './check'
1212import { Diagnostics } from './diagnostics'
1313import { validateRemovedDoubleCheck } from './internal/common-diagnostics'
14+ import { InvalidPropertyValueDiagnostic } from './construct-diagnostics'
15+
16+ /**
17+ * Retry strategies supported by monitors.
18+ */
19+ export type MonitorRetryStrategy = SingleRetryStrategy
1420
1521export interface MonitorProps extends Omit < CheckProps , 'doubleCheck' > {
1622 /**
@@ -74,8 +80,19 @@ export interface MonitorProps extends Omit<CheckProps, 'doubleCheck'> {
7480 /**
7581 * Sets a retry policy for the monitor. Use RetryStrategyBuilder to create a
7682 * suitable retry strategy.
83+ *
84+ * Note that monitors only support a single retry.
85+ *
86+ * @example
87+ * ```typescript
88+ * // Single retry
89+ * RetryStrategyBuilder.singleRetry()
90+ *
91+ * // No retries
92+ * RetryStrategyBuilder.noRetries()
93+ * ```
7794 */
78- retryStrategy ?: RetryStrategy
95+ retryStrategy ?: MonitorRetryStrategy
7996 /**
8097 * Determines whether the monitor should create and resolve an incident
8198 * based on its alert configuration.
@@ -95,6 +112,29 @@ export abstract class Monitor extends Check {
95112 await validateRemovedDoubleCheck ( diagnostics , this )
96113 }
97114
115+ async validate ( diagnostics : Diagnostics ) : Promise < void > {
116+ await super . validate ( diagnostics )
117+
118+ if ( this . retryStrategy ) {
119+ const supported : RetryStrategyType [ ] = [ 'SINGLE' , 'NO_RETRIES' ]
120+ if ( ! supported . includes ( this . retryStrategy . type ) ) {
121+ diagnostics . add ( new InvalidPropertyValueDiagnostic (
122+ 'retryStrategy' ,
123+ new Error (
124+ `Monitors only support a single retry. The following options ` +
125+ `are available:` +
126+ `\n\n` +
127+ ` // Single retry\n` +
128+ ` RetryStrategyBuilder.singleRetry()` +
129+ `\n\n` +
130+ ` // No retries\n` +
131+ ` RetryStrategyBuilder.noRetries()` ,
132+ ) ,
133+ ) )
134+ }
135+ }
136+ }
137+
98138 synthesize ( ) {
99139 return {
100140 ...super . synthesize ( ) ,
0 commit comments