(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-store-derivation) (re-export datastore-store-build) (re-export datastore-new-agent) (re-export datastore-list-agents) (re-export datastore-find-agent) (re-export datastore-store-build-result) (re-export datastore-fetch-setup-failures) (re-export datastore-list-build-outputs) (re-export datastore-list-related-derivations-with-no-build) (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-find-build) (re-export datastore-list-builds-for-derivation) (re-export datastore-list-unprocessed-builds) (re-export datastore-list-agent-builds) (re-export datastore-find-derivation-outputs) (re-export datastore-find-derivation-system) (re-export datastore-find-derivation-inputs) (re-export datastore-list-builds-for-output) (re-export datastore-agent-for-build) (re-export datastore-replace-build-allocation-plan) (re-export datastore-allocate-builds-to-agent) (re-export datastore-list-allocation-plan-builds) (define (database-uri->datastore database) (cond ((string-prefix? "pg://" database) (postgresql-datastore database)) ((string-prefix? "sqlite://" database) (sqlite-datastore database)) (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) (when (string=? (assq-ref output 'name) output-name) (assq-ref output 'output))) outputs)))