2016-11-20 21:13:40 +00:00
|
|
|
#lang syndicate/actor
|
|
|
|
|
2016-11-20 21:54:54 +00:00
|
|
|
(require racket/cmdline)
|
|
|
|
(require racket/set)
|
|
|
|
|
2016-11-20 21:13:40 +00:00
|
|
|
(require "private/util.rkt")
|
|
|
|
(require "protocol.rkt")
|
|
|
|
|
2016-11-20 22:51:38 +00:00
|
|
|
(require/activate syndicate/drivers/timestate)
|
2016-11-20 21:13:40 +00:00
|
|
|
(require/activate "config.rkt")
|
|
|
|
(require/activate "hub/static-content.rkt")
|
|
|
|
(require/activate "hub/topic-demand.rkt")
|
|
|
|
(require/activate "hub/local-topic.rkt")
|
|
|
|
(require/activate "hub/subscription.rkt")
|
|
|
|
|
2016-11-20 21:54:54 +00:00
|
|
|
(command-line #:program "racketmq"
|
|
|
|
|
|
|
|
#:once-each
|
|
|
|
["--canonical-host" host port "Specify the canonical host and port for this hub"
|
|
|
|
(actor #:name (list 'command-line-canonical-host host port)
|
|
|
|
(assert (config (list 'canonical-host host (string->number port)))))]
|
|
|
|
|
|
|
|
#:multi
|
|
|
|
[("-c" "--config") filename "Specify a configuration file to load"
|
|
|
|
(spawn-configuration filename)])
|
2016-11-20 21:13:40 +00:00
|
|
|
|
|
|
|
(actor #:name 'main
|
2016-11-20 21:55:06 +00:00
|
|
|
|
2016-11-20 21:13:40 +00:00
|
|
|
(during (config (list 'canonical-host $h $p))
|
|
|
|
(assert (canonical-local-host h p))
|
|
|
|
(assert (local-host h p)))
|
2016-11-20 21:55:06 +00:00
|
|
|
|
|
|
|
(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."))
|
2016-11-20 22:51:38 +00:00
|
|
|
(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")))
|
2016-11-20 21:55:06 +00:00
|
|
|
;; 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.
|
|
|
|
|
2016-11-20 21:13:40 +00:00
|
|
|
(during (config (list 'accepted-host $h $p))
|
|
|
|
(assert (local-host h p)))
|
2016-11-20 21:55:06 +00:00
|
|
|
|
2016-11-20 21:13:40 +00:00
|
|
|
(during (local-host $host-name $port)
|
|
|
|
(assert (vh host-name port))))
|