-
Notifications
You must be signed in to change notification settings - Fork 127
Description
Hey there! First of all, thank you for this great piece of software.
I'm not sure if that's a proper way to ask general best-practice questions but let's give it a shot. If not, please forgive me.
I'm building a system which receives a pretty complicated JSON object and needs to validate it async and, if it's valid, it needs to make a further work. Obviously that's a really simplified description of what's really going on.
As those incoming JSON objects are kind of like commands of what to do with actual models (Create/Update/Vote/etc), i decided to go for RES and test it out. Everythng goes smoothly so far but i'm unsure about one detail. Let's say steps are as follows:
- JSON object comes in
ActivityCreatedevent is created in RES- JSON validation is being done using RES subscribers (async)
- If
Activityis successfull,ActivityAcceptedevent is created - otherwise,
ActivityRejectedevent is created
Apps using that can subscribe to ActivityAccepted event and do further work. By "further work" i mean reading data from the JSON object persisted in step 2.
Right now, i subscribe to ActivityAccepted and gets the received JSON using the following code instead of storing the same JSON with ActivityAccepted event:
class OnActivityAccepted
def call(event)
id = event.causation_id
Rails.configuration.event_store.read.event(id) # to fetch the contents of parent event
end
end
As it works pretty well, is that a proper way of dealing with data in ES world? Should i pass the original JSON to the ActivityAccepted event (and any other further event)? Are there any best practices regarding that? Right now, the only contents of ActivityAccepted event are the state changed to accepted
Thanks in advance for any tips!