-
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.
Merge pull request #624 from RailsEventStore/rl/remove-pubsub-module
Rename RubyEventStore::PubSub::* -> RubyEventStore::*
- Loading branch information
Showing
20 changed files
with
301 additions
and
248 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
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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module RubyEventStore | ||
class Broker | ||
def initialize(subscriptions:, dispatcher:) | ||
@subscriptions = subscriptions | ||
@dispatcher = dispatcher | ||
end | ||
|
||
def call(event, serialized_event) | ||
subscribers = subscriptions.all_for(event.type) | ||
subscribers.each do |subscriber| | ||
dispatcher.call(subscriber, event, serialized_event) | ||
end | ||
end | ||
|
||
def add_subscription(subscriber, event_types) | ||
verify_subscription(subscriber) | ||
subscriptions.add_subscription(subscriber, event_types) | ||
end | ||
|
||
def add_global_subscription(subscriber) | ||
verify_subscription(subscriber) | ||
subscriptions.add_global_subscription(subscriber) | ||
end | ||
|
||
def add_thread_subscription(subscriber, event_types) | ||
verify_subscription(subscriber) | ||
subscriptions.add_thread_subscription(subscriber, event_types) | ||
end | ||
|
||
def add_thread_global_subscription(subscriber) | ||
verify_subscription(subscriber) | ||
subscriptions.add_thread_global_subscription(subscriber) | ||
end | ||
|
||
private | ||
attr_reader :subscriptions, :dispatcher | ||
|
||
def verify_subscription(subscriber) | ||
raise SubscriberNotExist, "subscriber must be first argument or block" unless subscriber | ||
raise InvalidHandler.new("Handler #{subscriber} is invalid for dispatcher #{dispatcher}") unless dispatcher.verify(subscriber) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module RubyEventStore | ||
class Dispatcher | ||
def call(subscriber, event, _) | ||
subscriber = subscriber.new if Class === subscriber | ||
subscriber.call(event) | ||
end | ||
|
||
def verify(subscriber) | ||
begin | ||
subscriber_instance = Class === subscriber ? subscriber.new : subscriber | ||
rescue ArgumentError | ||
false | ||
else | ||
subscriber_instance.respond_to?(:call) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module RubyEventStore | ||
module PubSub | ||
def self.const_missing(const_name) | ||
if const_name.equal?(:Subscriptions) | ||
warn "`RubyEventStore::PubSub::Subscriptions` has been deprecated. Use `RubyEventStore::Subscriptions` instead." | ||
|
||
Subscriptions | ||
elsif const_name.equal?(:Broker) | ||
warn "`RubyEventStore::PubSub::Broker` has been deprecated. Use `RubyEventStore::Broker` instead." | ||
|
||
Broker | ||
elsif const_name.equal?(:Dispatcher) | ||
warn "`RubyEventStore::PubSub::Dispatcher` has been deprecated. Use `RubyEventStore::Dispatcher` instead." | ||
|
||
Dispatcher | ||
else | ||
super | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
ruby_event_store/lib/ruby_event_store/pub_sub/dispatcher.rb
This file was deleted.
Oops, something went wrong.
110 changes: 0 additions & 110 deletions
110
ruby_event_store/lib/ruby_event_store/pub_sub/subscriptions.rb
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
Oops, something went wrong.