Make fetching metrics work even when having database problems
This commit is contained in:
parent
f9bb60ab4a
commit
9dec45d2eb
2 changed files with 168 additions and 79 deletions
|
|
@ -273,10 +273,32 @@ available. Return the resource once PROC has returned."
|
|||
pool
|
||||
(lambda (resource) exp ...)))
|
||||
|
||||
(define (resource-pool-stats pool)
|
||||
(let ((reply (make-channel)))
|
||||
(put-message pool `(stats ,reply))
|
||||
(get-message reply)))
|
||||
(define* (resource-pool-stats pool #:key (timeout 5))
|
||||
(let ((reply (make-channel))
|
||||
(start-time (get-internal-real-time)))
|
||||
(perform-operation
|
||||
(choice-operation
|
||||
(wrap-operation
|
||||
(put-operation pool `(stats ,reply))
|
||||
(const #t))
|
||||
(wrap-operation (sleep-operation timeout)
|
||||
(const #f))))
|
||||
|
||||
(let ((time-remaining
|
||||
(- timeout
|
||||
(/ (- (get-internal-real-time)
|
||||
start-time)
|
||||
internal-time-units-per-second))))
|
||||
(if (> time-remaining 0)
|
||||
(let ((response
|
||||
(perform-operation
|
||||
(choice-operation
|
||||
(get-operation reply)
|
||||
(wrap-operation (sleep-operation time-remaining)
|
||||
(const #f))))))
|
||||
response)
|
||||
(raise-exception
|
||||
(make-resource-pool-timeout-error))))))
|
||||
|
||||
(define (defer-to-parallel-fiber thunk)
|
||||
(let ((reply (make-channel)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue