aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/datastore
diff options
context:
space:
mode:
Diffstat (limited to 'guix-build-coordinator/datastore')
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm39
1 files changed, 39 insertions, 0 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index 07b7aed..c7c4617 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -56,6 +56,7 @@
datastore-new-agent
datastore-list-agents
datastore-set-agent-active
+ datastore-update-agent-status
datastore-find-agent
datastore-find-agent-by-name
datastore-insert-dynamic-auth-token
@@ -675,6 +676,44 @@ UPDATE agents SET active = :active WHERE id = :uuid"
(sqlite-finalize statement))))
active?)
+(define-method (datastore-update-agent-status
+ (datastore <sqlite-datastore>)
+ agent-uuid
+ status
+ 1min-load-average)
+ (call-with-worker-thread
+ (slot-ref datastore 'worker-writer-thread-channel)
+ (lambda (db)
+ (let ((statement
+ (sqlite-prepare
+ db
+ "
+DELETE FROM agent_status WHERE agent_id = :uuid"
+ #:cache? #t)))
+
+ (sqlite-bind-arguments statement
+ #:uuid agent-uuid)
+ (sqlite-step statement)
+ (sqlite-reset statement))
+
+ (let ((statement
+ (sqlite-prepare
+ db
+ "
+INSERT INTO agent_status (agent_id, status, load_average_1min)
+ VALUES (:uuid, :status, :load)"
+ #:cache? #t)))
+
+ (sqlite-bind-arguments statement
+ #:uuid agent-uuid
+ #:status status
+ #:load 1min-load-average)
+
+ (sqlite-step statement)
+ (sqlite-reset statement))))
+
+ #t)
+
(define-method (datastore-new-agent-password
(datastore <sqlite-datastore>)
agent-uuid