-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce AsyncHandler and CorrelatedHandler helpers
which help with correlating commands/events coming from async handlers. Issue: #346
- Loading branch information
Showing
4 changed files
with
83 additions
and
63 deletions.
There are no files selected for viewing
26 changes: 15 additions & 11 deletions
26
rails_event_store/lib/rails_event_store/async_handler_helpers.rb
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
module AsyncHandler | ||
def perform(payload) | ||
super(Rails.configuration.event_store.deserialize(payload)) | ||
module RailsEventStore | ||
|
||
module AsyncHandler | ||
def perform(payload) | ||
super(Rails.configuration.event_store.deserialize(payload)) | ||
end | ||
end | ||
end | ||
|
||
module CorrelatedHandler | ||
def perform(event) | ||
Rails.configuration.event_store.with_metadata( | ||
correlation_id: event.metadata[:correlation_id] || event.event_id, | ||
causation_id: event.event_id | ||
) do | ||
super | ||
module CorrelatedHandler | ||
def perform(event) | ||
Rails.configuration.event_store.with_metadata( | ||
correlation_id: event.metadata[:correlation_id] || event.event_id, | ||
causation_id: event.event_id | ||
) do | ||
super | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains 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
This file contains 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
This file contains 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