racketmq-2017/racketmq/protocol.rkt

65 lines
2.5 KiB
Racket

#lang racket/base
;; Assertions, Messages and Protocols for RacketMQ
(provide (struct-out notification)
(struct-out update-subscription)
(struct-out subscription)
(struct-out subscription-settings)
(struct-out local-topic-config)
(struct-out topic-demand)
(struct-out local-topic-demand)
(struct-out remote-topic-demand)
(struct-out http-listener)
(struct-out canonical-baseurl))
;; A Topic is a URIString.
;; A Deadline is an (Option Number), where #f indicates "unbounded",
;; and numbers indicate a moment in time as a Unix epoch timestamp as
;; might be returned from `current-seconds`.
;; A Notification contains both `topic-name`, indicating the *local*
;; name for the topic that is being subscribed to, as well as
;; `canonical-topic`, which is the rel=self URL given by the upstream
;; topic itself. The former is our local key for finding resources;
;; the latter is a property of the topic content, not a property of
;; the subscription. The same is true of `canonical-hub`: it pertains
;; to the topic, not the subscription. The `topic-name` is the only
;; field pertaining to a subscription; all the others pertain to the
;; content.
(struct notification (topic-name ;; Topic
canonical-hub ;; Option URLString
canonical-topic ;; Option Topic
content ;; Bytes
content-type) ;; Option String
#:prefab) ;; MESSAGE
;; (update-subscription Topic URLString (Option SubscriptionSettings))
(struct update-subscription (topic callback settings) #:prefab) ;; MESSAGE
;; (subscription Topic URLString SubscriptionSettings)
(struct subscription (topic callback settings-) #:prefab) ;; ASSERTION
(struct subscription-settings (expiry-deadline ;; Deadline
secret ;; Option Bytes
poll-interval-seconds) ;; Option Number
#:prefab)
;; (local-topic-config Topic (Option Number) (Option Number))
(struct local-topic-config (name max-age max-count) #:prefab) ;; ASSERTION
;; (topic-demand Topic (Option Number))
(struct topic-demand (topic-name poll-interval-seconds) #:prefab) ;; ASSERTION
;; (local-topic-demand String)
(struct local-topic-demand (name) #:prefab) ;; ASSERTION
;; (remote-topic-demand Topic)
(struct remote-topic-demand (topic-name) #:prefab) ;; ASSERTION
;; (http-listener String Number)
(struct http-listener (name port) #:prefab) ;; ASSERTION
;; (canonical-baseurl URLString)
(struct canonical-baseurl (string) #:prefab) ;; ASSERTION