aboutsummaryrefslogtreecommitdiff
path: root/guix-build-coordinator/datastore/sqlite.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix-build-coordinator/datastore/sqlite.scm')
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm26
1 files changed, 26 insertions, 0 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index 89fea58..94a3154 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -47,6 +47,7 @@
datastore-list-build-outputs
datastore-new-agent
datastore-list-agents
+ datastore-set-agent-active
datastore-find-agent
datastore-find-agent-by-name
datastore-insert-dynamic-auth-token
@@ -593,6 +594,31 @@ SELECT id, name, description, active FROM agents ORDER BY id"
agents)))))
+(define-method (datastore-set-agent-active
+ (datastore <sqlite-datastore>)
+ agent-uuid
+ active?)
+ (unless (boolean? active?)
+ (error "datastore-set-agent-active called with non-boolean"))
+
+ (call-with-worker-thread
+ (slot-ref datastore 'worker-writer-thread-channel)
+ (lambda (db)
+ (let ((statement
+ (sqlite-prepare
+ db
+ "
+UPDATE agents SET active = :active WHERE id = :uuid"
+ #:cache? #f)))
+
+ (sqlite-bind-arguments statement
+ #:uuid agent-uuid
+ #:active (if active? 1 0))
+
+ (sqlite-step statement)
+ (sqlite-finalize statement))))
+ active?)
+
(define-method (datastore-new-agent-password
(datastore <sqlite-datastore>)
agent-uuid