From d83a87f0f4ff3323560ff00f3594d119fecb1e25 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 21 Nov 2016 11:51:38 +1300 Subject: [PATCH] Complain if no canonical-hosts are available --- racketmq/hub.rkt | 4 ++++ racketmq/private/util.rkt | 8 +------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/racketmq/hub.rkt b/racketmq/hub.rkt index ee59e83..6728bd9 100644 --- a/racketmq/hub.rkt +++ b/racketmq/hub.rkt @@ -6,6 +6,7 @@ (require "private/util.rkt") (require "protocol.rkt") +(require/activate syndicate/drivers/timestate) (require/activate "config.rkt") (require/activate "hub/static-content.rkt") (require/activate "hub/topic-demand.rkt") @@ -32,6 +33,9 @@ (define/query-set canonical-local-hosts ($ c (canonical-local-host _ _)) c) (stop-when (rising-edge (> (set-count (canonical-local-hosts)) 1)) (log-error "Too many canonical-host records in configuration.")) + (on-start (sleep 0.1) + (when (set-empty? (canonical-local-hosts)) + (log-error "No canonical-host records specified; try the --canonical-host command line argument"))) ;; TODO: Make the too-many-canonical-host-records situation recoverable. ;; TODO: And/or, make the whole application quit when it gets into a bad state. diff --git a/racketmq/private/util.rkt b/racketmq/private/util.rkt index 661b244..bc39949 100644 --- a/racketmq/private/util.rkt +++ b/racketmq/private/util.rkt @@ -1,7 +1,6 @@ #lang racket/base -(provide sleep - random-hex-string +(provide random-hex-string extend-url-string-query web-respond/status! web-request! @@ -23,11 +22,6 @@ (module+ test (require rackunit)) -(define (sleep sec) - (define timer-id (gensym 'sleep)) - (until (message (timer-expired timer-id _)) - (on-start (send! (set-timer timer-id (* sec 1000.0) 'relative))))) - (define (random-hex-string half-length) (bytes->hex-string (crypto-random-bytes half-length)))