mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 07:41:27 +00:00
refactor(db): port sleep/wake sweeper to sqlc (#81)
Tranche 7 — all 11 raw sites in sleeper.go. Adds sleep_enabled and sleep_idle_minutes to schema.sql and three runtime.sql queries: ListSleepCandidates, GetServiceDomainText, GetServiceStatusText. Status writes reuse SetServiceStatus; the wake loader reuses GetServiceRuntimeWithOwner (the projects join is FK-safe). Also drops a dead port read in handleServiceSleep that was loaded but never used. TestRuntimeLiveInvariants now covers the sweep filter and both text lookups on live Postgres. Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
269e031761
commit
81a4ca28d8
7 files changed
+173
-91
No files matched your search
@@ -45,3 +45,15 @@ UPDATE services SET published_port = $1 WHERE id = $2 AND published_port <> $1;
|
||||
|
||||
-- name: SetServiceReplicas :exec
|
||||
UPDATE services SET replicas = $1, updated_at = $2 WHERE id = $3;
|
||||
|
||||
-- name: ListSleepCandidates :many
|
||||
SELECT id, project_id, name, COALESCE(status,'') AS status,
|
||||
COALESCE(sleep_idle_minutes, 15) AS sleep_idle_minutes
|
||||
FROM services
|
||||
WHERE sleep_enabled AND COALESCE(status,'') IN ('running','deployed','degraded','starting');
|
||||
|
||||
-- name: GetServiceDomainText :one
|
||||
SELECT COALESCE(domain,'') AS domain FROM services WHERE id = $1;
|
||||
|
||||
-- name: GetServiceStatusText :one
|
||||
SELECT COALESCE(status,'') AS status FROM services WHERE id = $1;
|
||||
@@ -69,6 +69,8 @@ CREATE TABLE services (
|
||||
static_dir VARCHAR(255) NOT NULL DEFAULT '',
|
||||
node_id VARCHAR(255),
|
||||
spread BOOLEAN NOT NULL DEFAULT false,
|
||||
sleep_enabled BOOLEAN NOT NULL DEFAULT false,
|
||||
sleep_idle_minutes INTEGER NOT NULL DEFAULT 15,
|
||||
placement_tags JSONB NOT NULL DEFAULT '[]',
|
||||
traefik_labels JSONB NOT NULL DEFAULT '{}'
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user