feat(statuspage): fetch every served page every five minutes
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Canceled after 5m23s
ci / test (pull_request) Canceled after 5m23s
ci / build (pull_request) Canceled after 0s
ci / image (pull_request) Canceled after 0s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Canceled after 5m23s
ci / test (pull_request) Canceled after 5m23s
ci / build (pull_request) Canceled after 0s
ci / image (pull_request) Canceled after 0s
A status page server only knew the pages visitors had asked it for, so during an API outage a server that had never seen a page could not serve it. The agent API now lists the pages a server serves (GET /agent/v1/pages/index), following the same rule as single pages, and status page servers fetch all of them on start and every five minutes, also dropping those no longer listed. Pages visited within the last ten minutes are still refreshed every 30 seconds; the outdated notice now appears after ten minutes, twice the sync interval. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
c0239e15bb
commit
4e9a198b2f
10 files changed
+217
-15
No files matched your search
@@ -337,6 +337,10 @@ type Querier interface {
|
||||
// page from a keyset cursor whose string key is monitor and region.
|
||||
ResultsByChecker(ctx context.Context, arg ResultsByCheckerParams) ([]ResultsByCheckerRow, error)
|
||||
ScrubAuditEmail(ctx context.Context, email string) error
|
||||
// System scope: the published pages a status page server serves, those
|
||||
// of agent_org for an organization's server; the platform's leave the
|
||||
// pages of organizations serving their own.
|
||||
ServablePages(ctx context.Context, agentOrg *uuid.UUID) ([]ServablePagesRow, error)
|
||||
SetAgentAllowPrivate(ctx context.Context, arg SetAgentAllowPrivateParams) (int64, error)
|
||||
SetIncidentTitle(ctx context.Context, arg SetIncidentTitleParams) (int64, error)
|
||||
SetOrgDisabledCheckTypes(ctx context.Context, arg SetOrgDisabledCheckTypesParams) error
|
||||
|
||||
@@ -93,3 +93,17 @@ WHERE published AND suspended_at IS NULL
|
||||
AND NOT EXISTS (SELECT 1 FROM orgs o WHERE o.id = status_pages.org_id AND o.suspended_at IS NOT NULL)
|
||||
AND ((sqlc.narg(host)::citext IS NOT NULL AND custom_domain = sqlc.narg(host) AND domain_verified_at IS NOT NULL)
|
||||
OR (sqlc.narg(slug)::citext IS NOT NULL AND slug = sqlc.narg(slug)));
|
||||
|
||||
-- name: ServablePages :many
|
||||
-- System scope: the published pages a status page server serves, those
|
||||
-- of agent_org for an organization's server; the platform's leave the
|
||||
-- pages of organizations serving their own.
|
||||
SELECT p.slug, COALESCE(CASE WHEN p.domain_verified_at IS NOT NULL THEN p.custom_domain END, '')::text AS host
|
||||
FROM status_pages p
|
||||
JOIN orgs o ON o.id = p.org_id
|
||||
WHERE p.published AND p.suspended_at IS NULL AND o.suspended_at IS NULL
|
||||
AND CASE WHEN sqlc.narg(agent_org)::uuid IS NULL
|
||||
THEN NOT EXISTS (SELECT 1 FROM agents a WHERE a.org_id = p.org_id AND a.kind = 'statuspage' AND a.last_seen_at IS NOT NULL)
|
||||
ELSE p.org_id = sqlc.narg(agent_org)::uuid
|
||||
END
|
||||
ORDER BY p.slug;
|
||||
@@ -352,6 +352,46 @@ func (q *Queries) ReparentStatusPageGroupMonitors(ctx context.Context, arg Repar
|
||||
return err
|
||||
}
|
||||
|
||||
const servablePages = `-- name: ServablePages :many
|
||||
SELECT p.slug, COALESCE(CASE WHEN p.domain_verified_at IS NOT NULL THEN p.custom_domain END, '')::text AS host
|
||||
FROM status_pages p
|
||||
JOIN orgs o ON o.id = p.org_id
|
||||
WHERE p.published AND p.suspended_at IS NULL AND o.suspended_at IS NULL
|
||||
AND CASE WHEN $1::uuid IS NULL
|
||||
THEN NOT EXISTS (SELECT 1 FROM agents a WHERE a.org_id = p.org_id AND a.kind = 'statuspage' AND a.last_seen_at IS NOT NULL)
|
||||
ELSE p.org_id = $1::uuid
|
||||
END
|
||||
ORDER BY p.slug
|
||||
`
|
||||
|
||||
type ServablePagesRow struct {
|
||||
Slug string
|
||||
Host string
|
||||
}
|
||||
|
||||
// System scope: the published pages a status page server serves, those
|
||||
// of agent_org for an organization's server; the platform's leave the
|
||||
// pages of organizations serving their own.
|
||||
func (q *Queries) ServablePages(ctx context.Context, agentOrg *uuid.UUID) ([]ServablePagesRow, error) {
|
||||
rows, err := q.db.Query(ctx, servablePages, agentOrg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []ServablePagesRow{}
|
||||
for rows.Next() {
|
||||
var i ServablePagesRow
|
||||
if err := rows.Scan(&i.Slug, &i.Host); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const setStatusPageDomain = `-- name: SetStatusPageDomain :one
|
||||
UPDATE status_pages SET
|
||||
custom_domain = $1,
|
||||
|
||||
Reference in new issue
Block a user