diff --git a/Makefile b/Makefile index 81b6327..038ce7b 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,7 @@ generate: sqlc sqlc: go tool sqlc compile go tool sqlc generate - go tool gowrap gen -t opentelemetry -i QuerierTx -p ./ntpdb -o ./ntpdb/otel.go - #go tool mockery --dir ntpdb --name QuerierTx --config /dev/null + go tool gowrap gen -g -t opentelemetry -i QuerierTx -p ./ntpdb -o ./ntpdb/otel.go sign: drone sign --save ntppool/data-api diff --git a/go.mod b/go.mod index 89b7e55..e33fcae 100644 --- a/go.mod +++ b/go.mod @@ -136,8 +136,8 @@ require ( golang.org/x/text v0.27.0 // indirect golang.org/x/time v0.12.0 // indirect golang.org/x/tools v0.34.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20250728155136-f173205681a0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20250804133106-a7a43d27e69b // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect google.golang.org/grpc v1.74.2 // indirect google.golang.org/protobuf v1.36.6 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/go.sum b/go.sum index 43e3d47..578cd17 100644 --- a/go.sum +++ b/go.sum @@ -362,8 +362,12 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/api v0.0.0-20250728155136-f173205681a0 h1:0UOBWO4dC+e51ui0NFKSPbkHHiQ4TmrEfEZMLDyRmY8= google.golang.org/genproto/googleapis/api v0.0.0-20250728155136-f173205681a0/go.mod h1:8ytArBbtOy2xfht+y2fqKd5DRDJRUQhqbyEnQ4bDChs= +google.golang.org/genproto/googleapis/api v0.0.0-20250804133106-a7a43d27e69b h1:ULiyYQ0FdsJhwwZUwbaXpZF5yUE3h+RA+gxvBu37ucc= +google.golang.org/genproto/googleapis/api v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:oDOGiMSXHL4sDTJvFvIB9nRQCGdLP1o/iVaqQK8zB+M= google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0 h1:MAKi5q709QWfnkkpNQ0M12hYJ1+e8qYVDyowc4U1XZM= google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b h1:zPKJod4w6F1+nRGDI9ubnXYhU9NSWoFAijkHkUXeTK8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.74.2 h1:WoosgB65DlWVC9FqI82dGsZhWFNBSLjQ84bjROOpMu4= google.golang.org/grpc v1.74.2/go.mod h1:CtQ+BGjaAIXHs/5YS3i473GqwBBa1zGQNevxdeBEXrM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/ntpdb/models.go b/ntpdb/models.go index 44d639f..e271a08 100644 --- a/ntpdb/models.go +++ b/ntpdb/models.go @@ -148,6 +148,7 @@ const ( ServerScoresStatusCandidate ServerScoresStatus = "candidate" ServerScoresStatusTesting ServerScoresStatus = "testing" ServerScoresStatusActive ServerScoresStatus = "active" + ServerScoresStatusPaused ServerScoresStatus = "paused" ) func (e *ServerScoresStatus) Scan(src interface{}) error { diff --git a/ntpdb/otel.go b/ntpdb/otel.go index 732a1c8..7300b9e 100644 --- a/ntpdb/otel.go +++ b/ntpdb/otel.go @@ -4,8 +4,6 @@ package ntpdb -//go:generate gowrap gen -p go.ntppool.org/data-api/ntpdb -i QuerierTx -t https://raw.githubusercontent.com/hexdigest/gowrap/6bd1bc023b4d2a619f30020924f258b8ff665a7a/templates/opentelemetry -o otel.go -l "" - import ( "context" diff --git a/schema.sql b/schema.sql index 63c19d5..fb51e8e 100644 --- a/schema.sql +++ b/schema.sql @@ -491,17 +491,20 @@ CREATE TABLE `server_scores` ( `score_ts` datetime DEFAULT NULL, `score_raw` double NOT NULL DEFAULT '0', `stratum` tinyint unsigned DEFAULT NULL, - `status` enum('candidate','testing','active') NOT NULL DEFAULT 'candidate', + `status` enum('candidate','testing','active','paused') NOT NULL DEFAULT 'candidate', `queue_ts` datetime DEFAULT NULL, `created_on` datetime NOT NULL, `modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `constraint_violation_type` varchar(50) DEFAULT NULL, `constraint_violation_since` datetime DEFAULT NULL, + `last_constraint_check` datetime DEFAULT NULL, + `pause_reason` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `server_id` (`server_id`,`monitor_id`), KEY `monitor_id` (`monitor_id`,`server_id`), KEY `monitor_id_2` (`monitor_id`,`score_ts`), KEY `idx_constraint_violation` (`constraint_violation_type`,`constraint_violation_since`), + KEY `idx_paused_monitors` (`status`,`last_constraint_check`,`pause_reason`), CONSTRAINT `server_score_monitor_fk` FOREIGN KEY (`monitor_id`) REFERENCES `monitors` (`id`), CONSTRAINT `server_score_server_id` FOREIGN KEY (`server_id`) REFERENCES `servers` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; @@ -898,4 +901,4 @@ CREATE TABLE `zones` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */; --- Dump completed on 2025-08-03 0:43:29 +-- Dump completed on 2025-08-06 4:26:05