diff options
author | Christopher Baines <mail@cbaines.net> | 2020-05-03 13:23:43 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-05-03 13:23:43 +0100 |
commit | 6baef6ae25f5718ec0f2ba917628e56e2da8a78a (patch) | |
tree | 48586c6ceb3b6485fb6dc62fbad5944f6621ca31 /guix-data-service | |
parent | b4111af288a5ee3e0710edc79f6bc5d639366d0e (diff) | |
download | data-service-6baef6ae25f5718ec0f2ba917628e56e2da8a78a.tar data-service-6baef6ae25f5718ec0f2ba917628e56e2da8a78a.tar.gz |
Split out querying of build servers and substitute servers
These are related things, but somewhat separate. This change should make it
easier to deal with changes regarding querying build servers, and querying
substitute servers.
Diffstat (limited to 'guix-data-service')
-rw-r--r-- | guix-data-service/builds.scm | 27 | ||||
-rw-r--r-- | guix-data-service/substitutes.scm | 83 |
2 files changed, 83 insertions, 27 deletions
diff --git a/guix-data-service/builds.scm b/guix-data-service/builds.scm index bba5bb3..3182a07 100644 --- a/guix-data-service/builds.scm +++ b/guix-data-service/builds.scm @@ -172,8 +172,6 @@ WHERE derivation_output_details.path = $1" (simple-format #t "\nFetching pending builds\n") (process-pending-builds conn id url) - (simple-format #t "\nFetching narinfo files\n") - (fetch-narinfo-files conn id url revision-commits) (simple-format #t "\nFetching unseen derivations\n") (process-derivation-outputs conn id url @@ -617,28 +615,3 @@ LIMIT 30000")) result)))) vlist-null (exec-query conn query (list (number->string build-server-id))))) - -(define (fetch-narinfo-files conn build-server-id build-server-url revision-commits) - (define outputs - (select-outputs-without-known-nar-entries - conn - build-server-id - revision-commits)) - - (simple-format #t "Querying ~A outputs\n" - (length outputs)) - - (let ((narinfos - (lookup-narinfos (string-trim-right build-server-url #\/) outputs))) - - (simple-format #t "Got ~A narinfo files\n" - (length narinfos)) - - (unless (eq? (length narinfos) 0) - (with-postgresql-transaction - conn - (lambda (conn) - (record-narinfo-details-and-return-ids - conn - build-server-id - narinfos)))))) diff --git a/guix-data-service/substitutes.scm b/guix-data-service/substitutes.scm new file mode 100644 index 0000000..6dd069e --- /dev/null +++ b/guix-data-service/substitutes.scm @@ -0,0 +1,83 @@ +;;; Guix Data Service -- Information about Guix over time +;;; Copyright © 2019, 2020 Christopher Baines <mail@cbaines.net> +;;; +;;; This program is free software: you can redistribute it and/or +;;; modify it under the terms of the GNU Affero General Public License +;;; as published by the Free Software Foundation, either version 3 of +;;; the License, or (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; Affero General Public License for more details. +;;; +;;; You should have received a copy of the GNU Affero General Public +;;; License along with this program. If not, see +;;; <http://www.gnu.org/licenses/>. + +(define-module (guix-data-service substitutes) + #:use-module (ice-9 match) + #:use-module (guix scripts substitute) + #:use-module (guix-data-service database) + #:use-module (guix-data-service model build-server) + #:use-module (guix-data-service model nar) + #:export (query-build-server-substitutes)) + +(define verbose-output? + (make-parameter #f)) + +(define* (query-build-server-substitutes conn build-server-ids revision-commits + outputs + #:key verbose?) + (parameterize + ((verbose-output? verbose?)) + (while #t + (let ((build-servers (select-build-servers conn))) + (for-each + (match-lambda + ((id url lookup-all-derivations?) + (when (or (or (not build-servers) + (not build-server-ids)) + (member id build-server-ids)) + (when lookup-all-derivations? + (simple-format #t "\nQuerying ~A\n" url) + (catch #t + (lambda () + (simple-format #t "\nFetching narinfo files\n") + (fetch-narinfo-files conn id url revision-commits + #:specific-outputs + outputs)) + (lambda (key . args) + (simple-format + (current-error-port) + "exception in query-build-server: ~A ~A\n" + key args))))))) + build-servers))))) + +(define* (fetch-narinfo-files conn build-server-id build-server-url + revision-commits + #:key specific-outputs) + (define outputs + (or specific-outputs + (select-outputs-without-known-nar-entries + conn + build-server-id + revision-commits))) + + (simple-format #t "Querying ~A outputs\n" + (length outputs)) + + (let ((narinfos + (lookup-narinfos (string-trim-right build-server-url #\/) outputs))) + + (simple-format #t "Got ~A narinfo files\n" + (length narinfos)) + + (unless (eq? (length narinfos) 0) + (with-postgresql-transaction + conn + (lambda (conn) + (record-narinfo-details-and-return-ids + conn + build-server-id + narinfos)))))) |