diff options
author | Christopher Baines <mail@cbaines.net> | 2020-04-09 21:43:55 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-04-10 20:34:47 +0100 |
commit | b53717dc09b87fd6c2d245e841620c91b918e994 (patch) | |
tree | 74f150becd59e2f4ab755b4999abcd9029a1cc43 /guix-build-coordinator | |
parent | 27c7e0dfe269627372100870b54a0381b6f26d03 (diff) | |
download | build-coordinator-b53717dc09b87fd6c2d245e841620c91b918e994.tar build-coordinator-b53717dc09b87fd6c2d245e841620c91b918e994.tar.gz |
Add the ability to list agents
Diffstat (limited to 'guix-build-coordinator')
-rw-r--r-- | guix-build-coordinator/datastore.scm | 3 | ||||
-rw-r--r-- | guix-build-coordinator/datastore/abstract.scm | 2 | ||||
-rw-r--r-- | guix-build-coordinator/datastore/sqlite.scm | 24 |
3 files changed, 27 insertions, 2 deletions
diff --git a/guix-build-coordinator/datastore.scm b/guix-build-coordinator/datastore.scm index 796f843..e76ce0c 100644 --- a/guix-build-coordinator/datastore.scm +++ b/guix-build-coordinator/datastore.scm @@ -6,7 +6,8 @@ ;; #:use-module (guix-build-coordinator datastore postgresql) #:re-export (datastore-store-derivation datastore-store-build - datastore-new-agent) + datastore-new-agent + datastore-list-agents) #:export (database-uri->datastore)) (define (database-uri->datastore database) diff --git a/guix-build-coordinator/datastore/abstract.scm b/guix-build-coordinator/datastore/abstract.scm index 6f684d0..b16a0c1 100644 --- a/guix-build-coordinator/datastore/abstract.scm +++ b/guix-build-coordinator/datastore/abstract.scm @@ -4,6 +4,7 @@ datastore-update datastore-store-derivation datastore-store-build + datastore-list-agents datastore-new-agent)) (define-class <abstract-datastore> ()) @@ -11,4 +12,5 @@ (define-generic datastore-store-derivation) (define-generic datastore-store-build) (define-generic datastore-new-agent) +(define-generic datastore-list-agents) (define-generic datastore-update) diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index d9ce272..daaa58e 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -12,7 +12,8 @@ datastore-update datastore-store-derivation datastore-store-build - datastore-new-agent)) + datastore-new-agent + datastore-list-agents)) (define-class <sqlite-datastore> (<abstract-datastore>) database-file @@ -50,6 +51,27 @@ (insert-agent db uuid description))) #t) +(define-method (datastore-list-agents + (datastore <sqlite-datastore>)) + (call-with-worker-thread + (slot-ref datastore 'worker-thread-channel) + (lambda (db) + (let ((statement + (sqlite-prepare + db + " +SELECT id, description FROM agents ORDER BY id"))) + + (let ((agents (sqlite-map + (match-lambda + (#(id description) + `((uuid . ,id) + (description . ,description)))) + statement))) + (sqlite-reset statement) + + agents))))) + (define-method (datastore-store-derivation (datastore <sqlite-datastore>) derivation) |