Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriptions redesigned #665

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
be31df8
Redefine subscriptions - breaking changes
mpraglowski Aug 9, 2019
39bc7ad
Refactor subscriptions
mpraglowski Aug 9, 2019
8ff0e36
Subscription storage is optional
mpraglowski Aug 9, 2019
972be0a
All dispatchers & schedulers receive now subscription object instead …
mpraglowski Aug 10, 2019
b693e49
Single subscriptions store is enough
mpraglowski Aug 16, 2019
33f34cb
Subscription global or assigned to specific type - it's just an imple…
mpraglowski Aug 16, 2019
2c9e3aa
Minor improvement & fixes
mpraglowski Aug 16, 2019
554cdbe
Docs & lint/specs for subscriptions store
mpraglowski Aug 16, 2019
4f76f27
Docs & specs for Subscription object
mpraglowski Aug 16, 2019
e18ceb3
No more local & global subscriptions, there are main subscription sto…
mpraglowski Aug 16, 2019
c8dedab
Do not need that anymore
mpraglowski Aug 16, 2019
29e62b4
Simplify subscriptions store API
mpraglowski Aug 16, 2019
acc8184
Must be excluded from mutation tests as test where it could be trigge…
mpraglowski Aug 16, 2019
2bd6c6d
Kill mutant
mpraglowski Aug 16, 2019
9aefcdf
Typo fix
mpraglowski Aug 16, 2019
636cafb
It does not make sense to require subscription store to be chainable
mpraglowski Aug 16, 2019
ff945e7
Fix subscriptions store lint namespace
mpraglowski Aug 16, 2019
cec639c
Add instrumented subscriptions store
mpraglowski Aug 16, 2019
b82767b
Use store factory for thread store instead of just a class
mpraglowski Aug 16, 2019
570590f
Again, keep Ruby 2.4 compatibility for now
mpraglowski Sep 6, 2019
7140093
Kill mutations
mpraglowski Sep 6, 2019
25dd989
Add frozen_string_literal: true in all changed files
mpraglowski Sep 6, 2019
4ba25e3
Document subscriptions provider class
mpraglowski Sep 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ruby_event_store/lib/ruby_event_store/subscription.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module RubyEventStore
class Subscription
def initialize(subscriber, event_types = [GLOBAL_SUBSCRIPTION], store: nil)
raise SubscriberNotExist, "subscriber must exists" unless subscriber
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🇬🇧


@subscriber = subscriber
@event_types = event_types
@store = store
Expand All @@ -15,6 +17,10 @@ def unsubscribe
event_types.each{ |type| @store.delete(self, type) } if @store
end

def global?
event_types.include?(GLOBAL_SUBSCRIPTION)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it always event_types == [GLOBAL_SUBSCRIPTION] or do we allow a Subscription to be both global and for some particular type?

end

def inspect
<<~EOS.strip
#<#{self.class}:0x#{__id__.to_s(16)}>
Expand All @@ -37,6 +43,7 @@ def ==(other)
other.event_types.eql?(event_types) &&
other.subscriber.eql?(subscriber)
end
alias_method :eql?, :==

# @private
BIG_VALUE = 0b11010000100100100101110000000010011110000110101011010001001110
Expand All @@ -50,9 +57,8 @@ def ==(other)
# This hash is based on
# * class
# * event types
# * subscriber objecy id
# * subscriber object id
def hash
# We don't use metadata because == does not use metadata
[
self.class,
event_types,
Expand Down