Make the build event handling code more generic
So that triggering a check for substitutes can be integrated in.
This commit is contained in:
parent
68850065d7
commit
7524d23b44
1 changed files with 48 additions and 36 deletions
|
|
@ -120,24 +120,7 @@
|
|||
(define build-server-id
|
||||
(string->number build-server-id-string))
|
||||
|
||||
(define (spawn-fiber-for-build-handler handler
|
||||
statuses
|
||||
data
|
||||
build-ids)
|
||||
(let ((ids
|
||||
(delete-duplicates
|
||||
(filter-map
|
||||
(lambda (build-id item-data)
|
||||
(if (and (string=? (assoc-ref item-data "type")
|
||||
"build")
|
||||
(member (assoc-ref item-data "event")
|
||||
statuses))
|
||||
build-id
|
||||
#f))
|
||||
build-ids
|
||||
data)
|
||||
=)))
|
||||
(unless (null? ids)
|
||||
(define (call-via-thread-pool-channel handler)
|
||||
(spawn-fiber
|
||||
(lambda ()
|
||||
(parallel-via-thread-pool-channel
|
||||
|
|
@ -153,11 +136,31 @@
|
|||
(lambda ()
|
||||
(with-throw-handler #t
|
||||
(lambda ()
|
||||
(handler conn ids))
|
||||
(handler conn))
|
||||
(lambda _
|
||||
(display (backtrace) (current-error-port))
|
||||
(display "\n" (current-error-port)))))
|
||||
#:unwind? #t)))))))))
|
||||
#:unwind? #t)))))))
|
||||
|
||||
(define (with-build-ids-for-status data
|
||||
build-ids
|
||||
statuses
|
||||
handler)
|
||||
(let ((ids
|
||||
(delete-duplicates
|
||||
(filter-map
|
||||
(lambda (build-id item-data)
|
||||
(if (and (string=? (assoc-ref item-data "type")
|
||||
"build")
|
||||
(member (assoc-ref item-data "event")
|
||||
statuses))
|
||||
build-id
|
||||
#f))
|
||||
build-ids
|
||||
data)
|
||||
=)))
|
||||
(unless (null? ids)
|
||||
(handler ids))))
|
||||
|
||||
(define (handle-derivation-events conn items)
|
||||
(if (null? items)
|
||||
|
|
@ -223,23 +226,32 @@
|
|||
conn
|
||||
filtered-items)))))))
|
||||
|
||||
(spawn-fiber-for-build-handler
|
||||
handle-removing-blocking-build-entries-for-successful-builds
|
||||
(with-build-ids-for-status
|
||||
items
|
||||
build-ids
|
||||
'("succeeded")
|
||||
items
|
||||
build-ids)
|
||||
(lambda (ids)
|
||||
(call-via-thread-pool-channel
|
||||
(lambda (conn)
|
||||
(handle-removing-blocking-build-entries-for-successful-builds conn ids)))))
|
||||
|
||||
(spawn-fiber-for-build-handler
|
||||
handle-blocked-builds-entries-for-scheduled-builds
|
||||
(with-build-ids-for-status
|
||||
items
|
||||
build-ids
|
||||
'("scheduled")
|
||||
items
|
||||
build-ids)
|
||||
(lambda (ids)
|
||||
(call-via-thread-pool-channel
|
||||
(lambda (conn)
|
||||
(handle-blocked-builds-entries-for-scheduled-builds conn ids)))))
|
||||
|
||||
(spawn-fiber-for-build-handler
|
||||
handle-populating-blocked-builds-for-build-failures
|
||||
'("failed" "failed-dependency" "canceled")
|
||||
(with-build-ids-for-status
|
||||
items
|
||||
build-ids)))
|
||||
build-ids
|
||||
'("failed" "failed-dependency" "canceled")
|
||||
(lambda (ids)
|
||||
(call-via-thread-pool-channel
|
||||
(lambda (conn)
|
||||
(handle-populating-blocked-builds-for-build-failures conn ids)))))))
|
||||
|
||||
(if (any-invalid-query-parameters? parsed-query-parameters)
|
||||
(render-json
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue