Line data Source code
1 4 : (ns matchscore.utils.domain-events
2 : (:import
3 : (java.time Instant)))
4 :
5 :
6 4 : (defn make-metadata
7 : "Build event metadata map with timestamp."
8 : [{:keys [user-uuid correlation-id causation-id]}]
9 54 : (cond-> {:timestamp (str (Instant/now))}
10 12 : user-uuid (assoc :user-uuid user-uuid)
11 4 : correlation-id (assoc :correlation-id correlation-id)
12 4 : causation-id (assoc :causation-id causation-id)))
13 :
14 :
15 4 : (defn make-event
16 : "Build a domain event map."
17 : [event-type payload metadata-opts]
18 20 : {:event-type event-type
19 4 : :payload payload
20 12 : :metadata (make-metadata metadata-opts)})
|