-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(TODO: Review this commit for future improvements on Eventwire)
- Loading branch information
Showing
14 changed files
with
37 additions
and
242 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
web: bundle exec thin start | ||
bus: bundle exec rake event_bus:start | ||
bus: bundle exec rake environment eventwire:work --trace |
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,5 +1,13 @@ | ||
Rails.application.class.configure do | ||
config.event_bus = 'EventBus::Redis' | ||
config.event_subscribers = %w{ClientReport ClientDetailsReport AccountDetailsReport MoneyTransferSaga} | ||
config.to_prepare { EventBus.init } | ||
config.to_prepare do | ||
# Initialize Eventwire before each request so that using the InProcess driver | ||
# in development the event handlers are declared only once | ||
Eventwire.driver = Rails.env.test? ? 'InProcess' : 'Redis' | ||
Eventwire.on_error do |ex| | ||
raise ex | ||
end | ||
ClientReport; ClientDetailsReport; AccountDetailsReport; MoneyTransferSaga | ||
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,13 +1,13 @@ | ||
module EventHandler | ||
include Eventwire::Subscriber::DSL | ||
|
||
def on(*events, &block) | ||
events.each do |event_name| | ||
::EventBus.subscribe(event_name, "#{name}:#{increment_handlers_count}:#{event_name}", &block) | ||
super(event_name) do |event| | ||
event.data = event.data.to_hash.symbolize_keys | ||
block.call(event) | ||
end | ||
end | ||
end | ||
|
||
def increment_handlers_count | ||
@handlers_count ||= 0 | ||
@handlers_count += 1 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
desc "Start Event Bus" | ||
task "event_bus:start" => :environment do | ||
EventBus.start | ||
end | ||
require 'eventwire/tasks' |
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