diff options
Diffstat (limited to 'guix-build-coordinator/datastore/sqlite.scm')
-rw-r--r-- | guix-build-coordinator/datastore/sqlite.scm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index c7c4617..ba4a6d4 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-find-agent-status datastore-update-agent-status datastore-find-agent datastore-find-agent-by-name @@ -676,6 +677,33 @@ UPDATE agents SET active = :active WHERE id = :uuid" (sqlite-finalize statement)))) active?) +(define-method (datastore-find-agent-status + (datastore <sqlite-datastore>) + agent-id) + (call-with-worker-thread + (slot-ref datastore 'worker-reader-thread-channel) + (lambda (db) + (let ((statement + (sqlite-prepare + db + " +SELECT status, load_average_1min +FROM agent_status +WHERE agent_id = :agent_id" + #:cache? #t))) + + (sqlite-bind-arguments + statement + #:agent_id agent-id) + + (match (sqlite-step statement) + (#(status 1min_load_average) + (sqlite-reset statement) + + `((status . ,status) + (1min_load_average . ,1min_load_average))) + (_ #f)))))) + (define-method (datastore-update-agent-status (datastore <sqlite-datastore>) agent-uuid |