diff options
author | Christopher Baines <mail@cbaines.net> | 2020-05-08 17:16:26 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-05-08 17:16:26 +0100 |
commit | 6315b898754c3a5fbbc0e752743b33c9175489b1 (patch) | |
tree | b8ed5375d110441e30d4c7ad48a486cd517587ef /guix-build-coordinator/agent-messaging | |
parent | c595d561896b3aa29106fb18e45fd737ab0de702 (diff) | |
download | build-coordinator-6315b898754c3a5fbbc0e752743b33c9175489b1.tar build-coordinator-6315b898754c3a5fbbc0e752743b33c9175489b1.tar.gz |
Make a record type for the build coordinator
This is already useful to pass around the datastore, hooks and metrics
registry, and will become more useful to pass around the allocator to use.
Diffstat (limited to 'guix-build-coordinator/agent-messaging')
-rw-r--r-- | guix-build-coordinator/agent-messaging/http.scm | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm index 103e962..676651c 100644 --- a/guix-build-coordinator/agent-messaging/http.scm +++ b/guix-build-coordinator/agent-messaging/http.scm @@ -76,9 +76,9 @@ if there was no request body." fixed/read-request-body) (define (http-agent-messaging-start-server port host secret-key-base - datastore hooks) + build-coordinator) (define trigger-build-allocation - (make-build-allocator-thread datastore)) + (make-build-allocator-thread build-coordinator)) (define chunked-request-channel ;; There are fibers issues when trying to read the chunked requests @@ -86,10 +86,9 @@ if there was no request body." #:parallelism 4)) (define update-base-datastore-metrics! - (base-datastore-metrics-updater datastore - coordinator-metrics-registry)) + (base-datastore-metrics-updater build-coordinator)) - (start-hook-processing-thread datastore hooks) + (start-hook-processing-thread build-coordinator) (trigger-build-allocation) (call-with-error-handling (lambda () @@ -106,7 +105,7 @@ if there was no request body." (uri-path (request-uri request)))) body secret-key-base - datastore + build-coordinator trigger-build-allocation chunked-request-channel update-base-datastore-metrics!))) @@ -150,10 +149,16 @@ port. Also, the port used can be changed by passing the --port option.\n" (list (build-response #:code 204) "")) -(define (base-datastore-metrics-updater datastore registry) +(define (base-datastore-metrics-updater build-coordinator) (define namespace "guixbuildcoordinator") + (define datastore + (build-coordinator-datastore build-coordinator)) + + (define registry + (build-coordinator-metrics-registry build-coordinator)) + (let ((builds-total (make-gauge-metric registry (string-append namespace @@ -216,7 +221,7 @@ port. Also, the port used can be changed by passing the --port option.\n" method-and-path-components body secret-key-base - datastore + build-coordinator trigger-build-allocation chunked-request-channel update-base-datastore-metrics!) @@ -238,6 +243,9 @@ port. Also, the port used can be changed by passing the --port option.\n" auth-password))) (_ #f)))) + (define datastore + (build-coordinator-datastore build-coordinator)) + (define (controller-thunk) (match method-and-path-components (('GET "agent" uuid) @@ -261,7 +269,7 @@ port. Also, the port used can be changed by passing the --port option.\n" #:code 403))) (('POST "agent" uuid "fetch-builds") (if (authenticated? uuid request) - (let ((builds (fetch-builds datastore uuid))) + (let ((builds (fetch-builds build-coordinator uuid))) (render-json `((builds . ,(list->vector builds))))) (render-json @@ -285,7 +293,8 @@ port. Also, the port used can be changed by passing the --port option.\n" (backtrace) (raise-exception exn)) (lambda () - (handle-build-result datastore agent-id-for-build uuid + (handle-build-result build-coordinator + agent-id-for-build uuid (json-string->scm (utf8->string body))) ;; Trigger build allocation, as the result of this build ;; could change the allocation @@ -371,7 +380,8 @@ port. Also, the port used can be changed by passing the --port option.\n" #:headers '((content-type . (text/plain)) (vary . (accept)))) (lambda (port) - (write-metrics coordinator-metrics-registry + (write-metrics (build-coordinator-metrics-registry + build-coordinator) port)))) (_ (render-json |