diff --git a/racketmq/hub/remote-topic.rkt b/racketmq/hub/remote-topic.rkt index 31e1c4a..e3b4e81 100644 --- a/racketmq/hub/remote-topic.rkt +++ b/racketmq/hub/remote-topic.rkt @@ -14,6 +14,13 @@ (require "../private/util.rkt") (require "../protocol.rkt") +(define (set-minimum xs) + (for/fold [(i #f)] [(candidate (in-set xs))] + (cond [(not candidate) i] + [(not i) candidate] + [(< candidate i) candidate] + [else i]))) + (define (remote-topic-main full-topic) (define sub-id (random-hex-string 16)) (log-info "Remote sub endpoint ~a" sub-id) @@ -29,10 +36,7 @@ (define/query-set poll-intervals (topic-demand full-topic $i) i) (define/query-config min-poll-interval 60) (begin/dataflow - (define candidate (for/fold [(i #f)] [(candidate (in-set (poll-intervals)))] - (cond [(not i) candidate] - [(< candidate i) candidate] - [else i]))) + (define candidate (set-minimum (poll-intervals))) (poll-interval-seconds (and candidate (max candidate (min-poll-interval))))) (begin/dataflow (log-info "Poll interval for ~a is now ~a"