aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-04-09 22:33:00 +0100
committerChristopher Baines <mail@cbaines.net>2020-04-10 20:34:47 +0100
commit8094709aeb975585b1c9290774c35a678b2f10a3 (patch)
tree322a9ad71b5e41f28ae5bbaf489ec96b9bfdeed8
parent75af9de6819357d632fdbf8e3c21958dbc882f0c (diff)
downloadbuild-coordinator-8094709aeb975585b1c9290774c35a678b2f10a3.tar
build-coordinator-8094709aeb975585b1c9290774c35a678b2f10a3.tar.gz
Implement finding agents
-rw-r--r--guix-build-coordinator/datastore.scm1
-rw-r--r--guix-build-coordinator/datastore/abstract.scm2
-rw-r--r--guix-build-coordinator/datastore/sqlite.scm29
3 files changed, 32 insertions, 0 deletions
diff --git a/guix-build-coordinator/datastore.scm b/guix-build-coordinator/datastore.scm
index 951c307..ab806b6 100644
--- a/guix-build-coordinator/datastore.scm
+++ b/guix-build-coordinator/datastore.scm
@@ -8,6 +8,7 @@
datastore-store-build
datastore-new-agent
datastore-list-agents
+ datastore-find-agent
datastore-new-agent-password)
#:export (database-uri->datastore))
diff --git a/guix-build-coordinator/datastore/abstract.scm b/guix-build-coordinator/datastore/abstract.scm
index 7fcbe60..91f87da 100644
--- a/guix-build-coordinator/datastore/abstract.scm
+++ b/guix-build-coordinator/datastore/abstract.scm
@@ -5,6 +5,7 @@
datastore-store-derivation
datastore-store-build
datastore-list-agents
+ datastore-find-agent
datastore-new-agent
datastore-new-agent-password))
@@ -14,5 +15,6 @@
(define-generic datastore-store-build)
(define-generic datastore-new-agent)
(define-generic datastore-list-agents)
+(define-generic datastore-find-agent)
(define-generic datastore-new-agent-password)
(define-generic datastore-update)
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm
index a2a1a79..19e0f3e 100644
--- a/guix-build-coordinator/datastore/sqlite.scm
+++ b/guix-build-coordinator/datastore/sqlite.scm
@@ -14,6 +14,7 @@
datastore-store-build
datastore-new-agent
datastore-list-agents
+ datastore-find-agent
datastore-new-agent-password))
(define-class <sqlite-datastore> (<abstract-datastore>)
@@ -42,6 +43,34 @@
datastore))
+(define-method (datastore-find-agent
+ (datastore <sqlite-datastore>)
+ uuid)
+ (call-with-worker-thread
+ (slot-ref datastore 'worker-thread-channel)
+ (lambda (db)
+ (let ((statement
+ (sqlite-prepare
+ db
+ "
+SELECT description FROM agents WHERE id = :id")))
+
+ (sqlite-bind-arguments
+ statement
+ #:id uuid)
+
+ (let ((result
+ (match (sqlite-map
+ (match-lambda
+ (#(description)
+ `((description . ,description))))
+ statement)
+ (() #f)
+ ((agent) agent))))
+ (sqlite-reset statement)
+
+ result)))))
+
(define-method (datastore-new-agent
(datastore <sqlite-datastore>)
uuid