Last active
July 14, 2016 01:38
-
-
Save jdubie/eb9d2a91e5cee2fe33116e88b4197f0d to your computer and use it in GitHub Desktop.
Eventbus API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; assume 1 channel, and user id is always the shared key (kafka) | |
;; use cases | |
;; - logging (existing ladder.logging) | |
;; - publishing results of mutations with request infomation | |
(require '[ladder.logging :as log]) | |
;; logging | |
(log/info :foo/bar {:baz :quz}) | |
;; results in this being published | |
{:message/type :log/message | |
:message/payload {:log/type :foo/bar | |
:log/payload {:baz :quz} | |
:log/level :log.level/info} | |
:message/context {:user/id #uuid"3d1abc47-f5c7-4a94-af58-3f9b696a0258" | |
:request/id #uuid"5f1e42a0-58d2-4fa8-a154-f40d679fa3df" | |
:transaction/id #uuid"ea531767-2172-425a-aab2-9c7cd5ad7549" | |
:mutation/symbol 'beta/signup} | |
;; publishing results of mutations | |
(bus/pub :mutation/result | |
(merge | |
;; (:transaction/data request) | |
{:request/remote-addr "127.0.0.1" | |
:request/user-agent "Mozilla ..." | |
:request/referer "https://google.com" | |
:request/params [(beta/signup {:foo :bar}) [:beta/state :beta/loading]] | |
:user/id #uuid"3d1abc47-f5c7-4a94-af58-3f9b696a0258" ; probably fine is this is duplicated in context | |
:session/id #uuid"cfe064ab-ee5b-420b-88b3-f8987707a1a6" | |
:device/id #uuid"05ba90b1-6ee9-4d13-93ff-bef8b441d8e9"} | |
{:mutation/result {'beta/signup {:status 200 :foo :bar}}}) | |
;; results in this being published | |
{:message/type :mutation/result | |
:message/payload {:request/remote-addr "127.0.0.1" | |
:request/user-agent "Mozilla ..." | |
:request/referer "https://google.com" | |
:request/params [(beta/signup {:foo :bar}) [:beta/state :beta/loading]] | |
:user/id #uuid"3d1abc47-f5c7-4a94-af58-3f9b696a0258" ; probably fine is this is duplicated in context | |
:session/id #uuid"cfe064ab-ee5b-420b-88b3-f8987707a1a6" | |
:device/id #uuid"05ba90b1-6ee9-4d13-93ff-bef8b441d8e9" | |
:mutation/result {'beta/signup {:status 200 :foo :bar}}} | |
:message/context {:user/id #uuid"3d1abc47-f5c7-4a94-af58-3f9b696a0258" | |
:request/id #uuid"5f1e42a0-58d2-4fa8-a154-f40d679fa3df" | |
:transaction/id #uuid"ea531767-2172-425a-aab2-9c7cd5ad7549" | |
:mutation/symbol 'beta/signup}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
added
:mutation/params
in:message/payload
for mutations