diff options
author | Christopher Baines <mail@cbaines.net> | 2022-06-30 18:47:10 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2022-06-30 20:50:19 +0100 |
commit | 23504e0f01dc1eae05b307e313ba70faaad84be8 (patch) | |
tree | 0831e28cd26a1bcb46da02580305901154b21471 /guix-build-coordinator/datastore/sqlite.scm | |
parent | 70c83f81db4a6dd9ad94d4ec2b3b3be62bd0f467 (diff) | |
download | build-coordinator-23504e0f01dc1eae05b307e313ba70faaad84be8.tar build-coordinator-23504e0f01dc1eae05b307e313ba70faaad84be8.tar.gz |
Support processing hook events in parallel
Forcing hooks to be sequential simplifies them, and the implementation, but it
doesn't always scale well. I'm particularly thinking about the build-submitted
hook and built-success hooks, the processing of which can back up if there's
lots of builds being submitted or finishing successfully.
This new functionality allows hooks to be processed in parallel, which should
allow to manage this more effectively.
Diffstat (limited to 'guix-build-coordinator/datastore/sqlite.scm')
-rw-r--r-- | guix-build-coordinator/datastore/sqlite.scm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/guix-build-coordinator/datastore/sqlite.scm b/guix-build-coordinator/datastore/sqlite.scm index bbd9c28..a6c93f3 100644 --- a/guix-build-coordinator/datastore/sqlite.scm +++ b/guix-build-coordinator/datastore/sqlite.scm @@ -80,6 +80,7 @@ datastore-insert-unprocessed-hook-event datastore-count-unprocessed-hook-events datastore-list-unprocessed-hook-events + datastore-find-unprocessed-hook-event datastore-delete-unprocessed-hook-event datastore-list-agent-builds datastore-agent-for-build @@ -2480,6 +2481,37 @@ LIMIT :limit" events))))) +(define-method (datastore-find-unprocessed-hook-event + (datastore <sqlite-datastore>) + id) + (call-with-worker-thread + (slot-ref datastore 'worker-reader-thread-channel) + (lambda (db) + (let ((statement + (sqlite-prepare + db + " +SELECT event, arguments +FROM unprocessed_hook_events +WHERE id = :id" + #:cache? #t))) + + (sqlite-bind-arguments + statement + #:id id) + + (let ((result + (match (sqlite-step statement) + (#f #f) + (#(event arguments) + (list (string->symbol event) + (call-with-input-string arguments + (lambda (port) + (read port)))))))) + (sqlite-reset statement) + + result))))) + (define-method (datastore-delete-unprocessed-hook-event (datastore <sqlite-datastore>) id) |