aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-04-29 11:22:15 +0200
committerChristopher Baines <mail@cbaines.net>2023-04-29 11:22:15 +0200
commit214d44ca66fddfda5c23560de6fbd5d541caadb9 (patch)
tree6ccf0b59e078bab285f79463e78685424ec2b5f4
parent650fd773f7ffc9e8819e9b3ee47b414cc817bcb3 (diff)
downloadbffe-214d44ca66fddfda5c23560de6fbd5d541caadb9.tar
bffe-214d44ca66fddfda5c23560de6fbd5d541caadb9.tar.gz
Reverse proxy the build, agent and agent allocation plan responses
From the coordinator. This is so the bffe can render pages based on this data.
-rw-r--r--bffe/server.scm32
1 files changed, 32 insertions, 0 deletions
diff --git a/bffe/server.scm b/bffe/server.scm
index 8157843..cf1fa30 100644
--- a/bffe/server.scm
+++ b/bffe/server.scm
@@ -344,6 +344,7 @@
(define* (make-controller assets-directory metrics-registry
events-channel state-channel
+ event-source
title
template-directory)
@@ -430,6 +431,36 @@
(and=> (assoc-ref query-parameters "last_event_id")
string->number)))
#:unwind? #t))))))
+ (('GET "build" uuid)
+ (let ((response
+ body
+ (http-get
+ (string->uri
+ (string-append event-source "/build/" uuid)))))
+ (render-json
+ (json-string->scm
+ (utf8->string body)))))
+ (('GET "agent" agent-id)
+ (let ((response
+ body
+ (http-get
+ (string->uri
+ (string-append event-source "/agent/" agent-id)))))
+ (render-json
+ (json-string->scm
+ (utf8->string body)))))
+ (('GET "agent" agent-id (or "build-allocation-plan"
+ ;; TODO Remove underscore variant
+ "build_allocation_plan"))
+ (let ((response
+ body
+ (http-get
+ (string->uri
+ (string-append event-source "/agent/" agent-id
+ "/build_allocation_plan")))))
+ (render-json
+ (json-string->scm
+ (utf8->string body)))))
(('GET "assets" rest ...)
(or (handle-static-assets (string-join rest "/")
@@ -506,6 +537,7 @@
(apply make-controller assets-directory
metrics-registry
events-channel state-channel
+ event-source
controller-args)))
;; Wait until the events channel catches up