Make send-message topic optional, defaulting to a publish of the body itself.
This commit is contained in:
parent
4bf766daff
commit
1b60994028
8
os2.rkt
8
os2.rkt
|
@ -27,7 +27,8 @@
|
||||||
(rename-out [make-add-role add-role])
|
(rename-out [make-add-role add-role])
|
||||||
(except-out (struct-out delete-role) delete-role)
|
(except-out (struct-out delete-role) delete-role)
|
||||||
(rename-out [make-delete-role delete-role])
|
(rename-out [make-delete-role delete-role])
|
||||||
(struct-out send-message)
|
(except-out (struct-out send-message) send-message)
|
||||||
|
(rename-out [make-send-message send-message])
|
||||||
(except-out (struct-out spawn) spawn)
|
(except-out (struct-out spawn) spawn)
|
||||||
(rename-out [make-spawn spawn])
|
(rename-out [make-spawn spawn])
|
||||||
(except-out (struct-out kill) kill)
|
(except-out (struct-out kill) kill)
|
||||||
|
@ -101,7 +102,7 @@
|
||||||
;; Ks are various TrapKs or #f, signifying lack of interest.
|
;; Ks are various TrapKs or #f, signifying lack of interest.
|
||||||
(struct add-role (topics handlers k) #:prefab)
|
(struct add-role (topics handlers k) #:prefab)
|
||||||
(struct delete-role (eid reason) #:prefab)
|
(struct delete-role (eid reason) #:prefab)
|
||||||
(struct send-message (topic body) #:prefab)
|
(struct send-message (body topic) #:prefab)
|
||||||
(struct spawn (main k) #:prefab)
|
(struct spawn (main k) #:prefab)
|
||||||
(struct kill (pid reason) #:prefab)
|
(struct kill (pid reason) #:prefab)
|
||||||
|
|
||||||
|
@ -152,6 +153,7 @@
|
||||||
(define (make-transition state . actions) (transition state actions))
|
(define (make-transition state . actions) (transition state actions))
|
||||||
(define (make-add-role topics handlers [k #f]) (add-role topics handlers k))
|
(define (make-add-role topics handlers [k #f]) (add-role topics handlers k))
|
||||||
(define (make-delete-role eid [reason #f]) (delete-role eid reason))
|
(define (make-delete-role eid [reason #f]) (delete-role eid reason))
|
||||||
|
(define (make-send-message body [topic (topic-publisher body)]) (send-message body topic))
|
||||||
(define (make-spawn main [k #f]) (spawn main k))
|
(define (make-spawn main [k #f]) (spawn main k))
|
||||||
(define (make-kill [pid #f] [reason #f]) (kill pid reason))
|
(define (make-kill [pid #f] [reason #f]) (kill pid reason))
|
||||||
|
|
||||||
|
@ -250,7 +252,7 @@
|
||||||
(match preaction
|
(match preaction
|
||||||
[(add-role topics hs k) (do-subscribe pid (ensure-topic-union topics) hs k state)]
|
[(add-role topics hs k) (do-subscribe pid (ensure-topic-union topics) hs k state)]
|
||||||
[(delete-role eid reason) (do-unsubscribe pid eid reason state)]
|
[(delete-role eid reason) (do-unsubscribe pid eid reason state)]
|
||||||
[(send-message topic body) (route-and-deliver topic body state)]
|
[(send-message body topic) (route-and-deliver topic body state)]
|
||||||
[(spawn main k) (do-spawn pid main k state)]
|
[(spawn main k) (do-spawn pid main k state)]
|
||||||
[(kill pid-to-kill reason) (do-kill (or pid-to-kill pid) reason state)]))
|
[(kill pid-to-kill reason) (do-kill (or pid-to-kill pid) reason state)]))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue