fix: retry interval
This commit is contained in:
@@ -15,7 +15,7 @@ const MonitorBody = t.Object({
|
||||
max_retries: t.Optional(t.Number({ minimum: 0, maximum: 10, default: 0, description: "Retry a failing check up to N times before declaring DOWN" })),
|
||||
retry_interval_s: t.Optional(t.Number({ minimum: 1, maximum: 600, default: 30, description: "Seconds between retries" })),
|
||||
resend_interval: t.Optional(t.Number({ minimum: 0, maximum: 1000, default: 0, description: "Re-alert every Nth consecutive down beat. 0 = never resend." })),
|
||||
cert_alert_days: t.Optional(t.Number({ minimum: 0, maximum: 365, default: 14, description: "Alert when TLS cert is within N days of expiry. 0 disables." })),
|
||||
cert_alert_days: t.Optional(t.Number({ minimum: 0, maximum: 365, default: 0, description: "Alert when TLS cert is within N days of expiry. 0 disables (default)." })),
|
||||
query: t.Optional(t.Any({ description: "PingQL query — filter conditions for up/down" })),
|
||||
regions: t.Optional(t.Array(t.String(), { description: "Regions to run checks from. Empty array = all regions." })),
|
||||
channel_ids: t.Optional(t.Array(t.String(), { description: "Notification channel IDs to attach to this monitor." })),
|
||||
@@ -58,6 +58,12 @@ export const monitors = new Elysia({ prefix: "/monitors" })
|
||||
return { error: `Minimum interval for ${plan} plan is ${limits.minIntervalS}s` };
|
||||
}
|
||||
|
||||
const retryGap = body.retry_interval_s ?? Math.max(30, limits.minIntervalS);
|
||||
if (retryGap < limits.minIntervalS) {
|
||||
set.status = 400;
|
||||
return { error: `Retry interval for ${plan} plan must be at least ${limits.minIntervalS}s` };
|
||||
}
|
||||
|
||||
const regions = body.regions ?? [];
|
||||
if (regions.length > limits.maxRegions) {
|
||||
set.status = 400;
|
||||
@@ -76,9 +82,9 @@ export const monitors = new Elysia({ prefix: "/monitors" })
|
||||
${body.timeout_ms ?? 10000},
|
||||
${interval},
|
||||
${body.max_retries ?? 0},
|
||||
${body.retry_interval_s ?? 30},
|
||||
${retryGap},
|
||||
${body.resend_interval ?? 0},
|
||||
${body.cert_alert_days ?? 14},
|
||||
${body.cert_alert_days ?? 0},
|
||||
${body.query ? sql.json(body.query) : null},
|
||||
${sql.array(regions)}
|
||||
)
|
||||
@@ -112,6 +118,11 @@ export const monitors = new Elysia({ prefix: "/monitors" })
|
||||
return { error: `Minimum interval for ${plan} plan is ${limits.minIntervalS}s` };
|
||||
}
|
||||
|
||||
if (body.retry_interval_s != null && body.retry_interval_s < limits.minIntervalS) {
|
||||
set.status = 400;
|
||||
return { error: `Retry interval for ${plan} plan must be at least ${limits.minIntervalS}s` };
|
||||
}
|
||||
|
||||
if (body.regions && body.regions.length > limits.maxRegions) {
|
||||
set.status = 400;
|
||||
return { error: `Free plan allows ${limits.maxRegions} region per monitor. Upgrade to use multi-region.` };
|
||||
|
||||
Reference in New Issue
Block a user