(define-module (guix-build-coordinator datastore) #:use-module (srfi srfi-1) #:use-module (oop goops) #:use-module (guix-build-coordinator datastore abstract) #:use-module (guix-build-coordinator datastore sqlite) #:use-module (guix-build-coordinator datastore postgresql) #:duplicates (merge-generics) #:export (database-uri->datastore datastore-find-build-output)) (re-export datastore-spawn-fibers) (re-export datastore-initialise-metrics!) (re-export datastore-update-metrics!) (re-export datastore-update) (re-export datastore-call-with-transaction) (re-export datastore-store-derivation) (re-export datastore-insert-build) (re-export datastore-cancel-build) (re-export datastore-new-agent) (re-export datastore-list-agents) (re-export datastore-find-agent) (re-export datastore-count-build-results) (re-export datastore-store-build-result) (re-export datastore-store-build-start) (re-export datastore-find-build-starts) (re-export datastore-count-setup-failures) (re-export datastore-list-setup-failures-for-build) (re-export datastore-fetch-setup-failures) (re-export datastore-list-build-outputs) (re-export datastore-list-related-derivations-with-no-build-for-outputs) (re-export datastore-list-failed-builds-with-blocking-count) (re-export datastore-list-builds-for-derivation-recursive-inputs) (re-export datastore-store-setup-failure) (re-export datastore-store-setup-failure/missing-inputs) (re-export datastore-list-setup-failure-missing-inputs) (re-export datastore-new-agent-password) (re-export datastore-agent-password-exists?) (re-export datastore-count-builds) (re-export datastore-for-each-build) (re-export datastore-find-build) (re-export datastore-list-builds) (re-export datastore-insert-build-tags) (re-export datastore-fetch-build-tags) (re-export datastore-find-build-result) (re-export datastore-find-build-derivation-system) (re-export datastore-count-builds-for-derivation) (re-export datastore-list-processed-builds) (re-export datastore-list-unprocessed-builds) (re-export datastore-fetch-build-ids-and-propagated-priorities-for-unprocessed-builds) (re-export datastore-insert-unprocessed-hook-event) (re-export datastore-count-unprocessed-hook-events) (re-export datastore-list-unprocessed-hook-events) (re-export datastore-delete-unprocessed-hook-event) (re-export datastore-list-agent-builds) (re-export datastore-find-derivation) (re-export datastore-find-derivation-outputs) (re-export datastore-find-derivation-system) (re-export datastore-find-derivation-inputs) (re-export datastore-find-derivation-for-output) (re-export datastore-list-builds-for-output) (re-export datastore-list-builds-for-output-and-system) (re-export datastore-agent-for-build) (re-export datastore-count-build-allocation-plan-entries) (re-export datastore-replace-build-allocation-plan) (re-export datastore-remove-build-from-allocation-plan) (re-export datastore-count-allocated-builds) (re-export datastore-agent-requested-systems) (re-export datastore-update-agent-requested-systems) (re-export datastore-allocate-builds-to-agent) (re-export datastore-list-allocation-plan-builds) (define* (database-uri->datastore database #:key metrics-registry) (cond ((string-prefix? "pg://" database) (postgresql-datastore database)) ((string-prefix? "sqlite://" database) (sqlite-datastore database #:metrics-registry metrics-registry)) (else (error (simple-format #f "Unknown database ~A" database))))) (define (datastore-find-build-output datastore build-id output-name) (let* ((build (datastore-find-build datastore build-id)) (outputs (datastore-find-derivation-outputs datastore (assq-ref build 'derivation-name)))) (any (lambda (output) (if (string=? (assq-ref output 'name) output-name) (assq-ref output 'output) #f)) outputs)))