rails_event_store 0.31.1 → 0.32.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9021e0a62f2cab10e085fc92f7cc027d402faff4faf7c37c4ac22f83c229db2
4
- data.tar.gz: c91f784bed01bf82051e0fb0484a68a3914c0cd1742c681850897f3dea1226de
3
+ metadata.gz: 13ff46085fbcdeaecb358c34eeb5d44e28e9e6faf46d51c1f59a2fb9aebbfbfb
4
+ data.tar.gz: 2e06d9c2d992829cbaae4b6016dbdca2a580381c0b5b07a8d6535c0318df9905
5
5
  SHA512:
6
- metadata.gz: ce797385c611d702b1198ca8a78ef285d63311f41abb5d3ca986fc4f97d4632206addd3014caf21616571eba9ae3a8f3bf32c0f0f1e10b99df943fdf66e48401
7
- data.tar.gz: ef89e18be44a397849271e650c48aa8aadf53a5bd0a61d943e1ac40a3f98af48e23b040a023e150d517639dcf39003a7493d1d37efd13afc811d63432108f2b1
6
+ metadata.gz: 45e142da1c62a00f6e0c46d6d60050905548947cc87934422f16c3851638a29d4e19801f1c8f8ff9e0ec033f3f58dda88441375566a408a0cfe8ee1d6f2a66ef
7
+ data.tar.gz: c068371effa39534e6d8d9b3c6e0eb4dc6797d4df60a37dfeeda7612ee4f1b35b36872ec65e447d39399c0e0e679d5544a266bffde9a1ee1c82261ec1d984153
data/Makefile CHANGED
@@ -1,10 +1,11 @@
1
1
  GEM_VERSION = $(shell cat ../RES_VERSION)
2
2
  GEM_NAME = rails_event_store
3
3
  REQUIRE = $(GEM_NAME)
4
- IGNORE = RailsEventStore.const_missing \
5
- RailsEventStore::Client\#initialize \
6
- RailsEventStore::AsyncProxyStrategy::AfterCommit::AsyncRecord\#rolledback! \
7
- RailsEventStore::AsyncProxyStrategy::AfterCommit::AsyncRecord\#before_committed!
4
+ IGNORE = RailsEventStore::Client\#initialize \
5
+ RailsEventStore::AfterCommitAsyncDispatcher::AsyncRecord\#rolledback! \
6
+ RailsEventStore::AsyncProxyStrategy::AfterCommit* \
7
+ RailsEventStore::ActiveJobDispatcher* \
8
+
8
9
  SUBJECT ?= RailsEventStore*
9
10
 
10
11
  install: ## Install gem dependencies
@@ -23,7 +24,7 @@ test: ## Run unit tests
23
24
 
24
25
  mutate: test ## Run mutation tests
25
26
  @echo "Running mutation tests"
26
- @bundle exec mutant --include lib \
27
+ @MUTATING=true bundle exec mutant --include lib \
27
28
  $(addprefix --require ,$(REQUIRE)) \
28
29
  $(addprefix --ignore-subject ,$(IGNORE)) \
29
30
  --use rspec "$(SUBJECT)"
@@ -1,12 +1,26 @@
1
1
  require 'active_job'
2
2
 
3
3
  module RailsEventStore
4
+ # @deprecated Use RailsEventStore::ComposedDispatcher and RailsEventStore::ActiveJobScheduler instead
4
5
  class ActiveJobDispatcher < RubyEventStore::AsyncDispatcher
5
6
  def initialize(proxy_strategy: AsyncProxyStrategy::Inline.new)
6
7
  super(proxy_strategy: proxy_strategy, scheduler: ActiveJobScheduler.new)
8
+ warn <<~EOW
9
+ RailsEventStore::ActiveJobDispatcher has been deprecated.
10
+
11
+ Use RailsEventStore::ComposedDispatcher and RailsEventStore::ActiveJobScheduler instead
12
+ EOW
7
13
  end
8
14
 
15
+ # @deprecated Use RailsEventStore::ActiveJobScheduler with RubyEventStore::ImmediateAsyncDispatcher or RailsEventStore::AfterCommitAsyncDispatcher instead
9
16
  class ActiveJobScheduler
17
+ def initialize
18
+ warn <<~EOW
19
+ RailsEventStore::ActiveJobDispatcher::ActiveJobScheduler has been deprecated.
20
+
21
+ Use RailsEventStore::ActiveJobScheduler with RubyEventStore::ImmediateAsyncDispatcher or RailsEventStore::AfterCommitAsyncDispatcher instead
22
+ EOW
23
+ end
10
24
  def call(klass, serialized_event)
11
25
  klass.perform_later(serialized_event.to_h)
12
26
  end
@@ -0,0 +1,11 @@
1
+ module RailsEventStore
2
+ class ActiveJobScheduler
3
+ def call(klass, serialized_event)
4
+ klass.perform_later(serialized_event.to_h)
5
+ end
6
+
7
+ def verify(subscriber)
8
+ Class === subscriber && !!(subscriber < ActiveJob::Base)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,52 @@
1
+ module RailsEventStore
2
+ class AfterCommitAsyncDispatcher
3
+ def initialize(scheduler:)
4
+ @scheduler = scheduler
5
+ end
6
+
7
+ def call(subscriber, _, serialized_event)
8
+ run do
9
+ @scheduler.call(subscriber, serialized_event)
10
+ end
11
+ end
12
+
13
+ def run(&schedule_proc)
14
+ if ActiveRecord::Base.connection.transaction_open?
15
+ ActiveRecord::Base.
16
+ connection.
17
+ current_transaction.
18
+ add_record(AsyncRecord.new(self, schedule_proc))
19
+ else
20
+ yield
21
+ end
22
+ end
23
+
24
+ def verify(subscriber)
25
+ @scheduler.verify(subscriber)
26
+ end
27
+
28
+ private
29
+ class AsyncRecord
30
+ def initialize(dispatcher, schedule_proc)
31
+ @dispatcher = dispatcher
32
+ @schedule_proc = schedule_proc
33
+ end
34
+
35
+ def committed!
36
+ schedule_proc.call
37
+ end
38
+
39
+ def rolledback!(*)
40
+ end
41
+
42
+ def before_committed!
43
+ end
44
+
45
+ def add_to_transaction
46
+ dispatcher.run(&schedule_proc)
47
+ end
48
+
49
+ attr_reader :schedule_proc, :dispatcher
50
+ end
51
+ end
52
+ end
@@ -3,10 +3,11 @@ require 'rails_event_store/async_proxy_strategy'
3
3
  require 'rails_event_store/active_job_dispatcher'
4
4
  require 'rails_event_store/async_handler_helpers'
5
5
  require 'rails_event_store/link_by_metadata'
6
+ require 'rails_event_store/after_commit_async_dispatcher'
7
+ require 'rails_event_store/active_job_scheduler'
6
8
  require 'rails_event_store/client'
7
9
  require 'rails_event_store/version'
8
10
  require 'rails_event_store/railtie'
9
- require 'rails_event_store/deprecations'
10
11
 
11
12
  module RailsEventStore
12
13
  Event = RubyEventStore::Event
@@ -26,4 +27,5 @@ module RailsEventStore
26
27
  PAGE_SIZE = RubyEventStore::PAGE_SIZE
27
28
  AsyncProxyStrategy::Inline = RubyEventStore::AsyncProxyStrategy::Inline
28
29
  AsyncDispatcher = RubyEventStore::AsyncDispatcher
30
+ ImmediateAsyncDispatcher = RubyEventStore::ImmediateAsyncDispatcher
29
31
  end
@@ -1,6 +1,15 @@
1
1
  module RailsEventStore
2
2
  module AsyncProxyStrategy
3
+ # @deprecated Use RailsEventStore::AfterCommitAsyncDispatcher instead
3
4
  class AfterCommit
5
+ def initialize
6
+ warn <<~EOW
7
+ RailsEventStore::AsyncProxyStrategy::AfterCommit has been deprecated.
8
+
9
+ Use RailsEventStore::AfterCommitAsyncDispatcher instead
10
+ EOW
11
+ end
12
+
4
13
  def call(schedule_proc)
5
14
  if ActiveRecord::Base.connection.transaction_open?
6
15
  ActiveRecord::Base.
@@ -5,14 +5,15 @@ module RailsEventStore
5
5
  def initialize(repository: RailsEventStoreActiveRecord::EventRepository.new,
6
6
  mapper: RubyEventStore::Mappers::Default.new,
7
7
  subscriptions: RubyEventStore::PubSub::Subscriptions.new,
8
- dispatcher: ActiveJobDispatcher.new,
9
- request_metadata: default_request_metadata,
10
- page_size: PAGE_SIZE)
11
- super(repository: repository,
8
+ dispatcher: RubyEventStore::ComposedDispatcher.new(
9
+ RubyEventStore::ImmediateAsyncDispatcher.new(scheduler: ActiveJobScheduler.new),
10
+ RubyEventStore::PubSub::Dispatcher.new),
11
+ request_metadata: default_request_metadata)
12
+ super(repository: RubyEventStore::InstrumentedRepository.new(repository, ActiveSupport::Notifications),
12
13
  mapper: mapper,
13
14
  subscriptions: subscriptions,
14
- dispatcher: dispatcher,
15
- page_size: page_size)
15
+ dispatcher: RubyEventStore::InstrumentedDispatcher.new(dispatcher, ActiveSupport::Notifications)
16
+ )
16
17
  @request_metadata = request_metadata
17
18
  end
18
19
 
@@ -2,26 +2,26 @@ module RailsEventStore
2
2
 
3
3
  class LinkByMetadata < RubyEventStore::LinkByMetadata
4
4
  def initialize(event_store: Rails.configuration.event_store, key:, prefix: nil)
5
- super(event_store: event_store, key: key, prefix: prefix)
5
+ super
6
6
  end
7
7
  end
8
8
 
9
9
  class LinkByCorrelationId < RubyEventStore::LinkByCorrelationId
10
10
  def initialize(event_store: Rails.configuration.event_store, prefix: nil)
11
- super(event_store: event_store, prefix: prefix)
11
+ super
12
12
  end
13
13
  end
14
14
 
15
15
  class LinkByCausationId < RubyEventStore::LinkByCausationId
16
16
  def initialize(event_store: Rails.configuration.event_store, prefix: nil)
17
- super(event_store: event_store, prefix: prefix)
17
+ super
18
18
  end
19
19
  end
20
20
 
21
21
  class LinkByEventType < RubyEventStore::LinkByEventType
22
22
  def initialize(event_store: Rails.configuration.event_store, prefix: nil)
23
- super(event_store: event_store, prefix: prefix)
23
+ super
24
24
  end
25
25
  end
26
-
27
- end
26
+
27
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsEventStore
2
- VERSION = "0.31.1"
2
+ VERSION = "0.32.0"
3
3
  end
@@ -31,14 +31,14 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency 'rails', '~> 5.2'
32
32
  spec.add_development_dependency 'sqlite3'
33
33
  spec.add_development_dependency 'rack-test'
34
- spec.add_development_dependency 'mutant-rspec', '~> 0.8.14'
34
+ spec.add_development_dependency 'mutant-rspec', '~> 0.8.17'
35
35
  spec.add_development_dependency 'google-protobuf', '~> 3.5.1.2'
36
36
  spec.add_development_dependency 'pry'
37
37
 
38
- spec.add_dependency 'ruby_event_store', '= 0.31.1'
39
- spec.add_dependency 'rails_event_store_active_record', '= 0.31.1'
40
- spec.add_dependency 'aggregate_root', '= 0.31.1'
41
- spec.add_dependency 'bounded_context', '= 0.31.1'
38
+ spec.add_dependency 'ruby_event_store', '= 0.32.0'
39
+ spec.add_dependency 'rails_event_store_active_record', '= 0.32.0'
40
+ spec.add_dependency 'aggregate_root', '= 0.32.0'
41
+ spec.add_dependency 'bounded_context', '= 0.32.0'
42
42
  spec.add_dependency 'activesupport', '>= 3.0'
43
43
  spec.add_dependency 'activemodel', '>= 3.0'
44
44
  spec.add_dependency 'activejob', '>= 3.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.1
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-17 00:00:00.000000000 Z
11
+ date: 2018-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.8.14
103
+ version: 0.8.17
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.8.14
110
+ version: 0.8.17
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: google-protobuf
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -142,56 +142,56 @@ dependencies:
142
142
  requirements:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: 0.31.1
145
+ version: 0.32.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
- version: 0.31.1
152
+ version: 0.32.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rails_event_store_active_record
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - '='
158
158
  - !ruby/object:Gem::Version
159
- version: 0.31.1
159
+ version: 0.32.0
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - '='
165
165
  - !ruby/object:Gem::Version
166
- version: 0.31.1
166
+ version: 0.32.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: aggregate_root
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 0.31.1
173
+ version: 0.32.0
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 0.31.1
180
+ version: 0.32.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: bounded_context
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - '='
186
186
  - !ruby/object:Gem::Version
187
- version: 0.31.1
187
+ version: 0.32.0
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - '='
193
193
  - !ruby/object:Gem::Version
194
- version: 0.31.1
194
+ version: 0.32.0
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: activesupport
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -261,11 +261,12 @@ files:
261
261
  - README.md
262
262
  - lib/rails_event_store.rb
263
263
  - lib/rails_event_store/active_job_dispatcher.rb
264
+ - lib/rails_event_store/active_job_scheduler.rb
265
+ - lib/rails_event_store/after_commit_async_dispatcher.rb
264
266
  - lib/rails_event_store/all.rb
265
267
  - lib/rails_event_store/async_handler_helpers.rb
266
268
  - lib/rails_event_store/async_proxy_strategy.rb
267
269
  - lib/rails_event_store/client.rb
268
- - lib/rails_event_store/deprecations.rb
269
270
  - lib/rails_event_store/link_by_metadata.rb
270
271
  - lib/rails_event_store/middleware.rb
271
272
  - lib/rails_event_store/railtie.rb
@@ -1,7 +0,0 @@
1
- module RailsEventStore
2
- def self.const_missing(const_name)
3
- super unless const_name == :MethodNotDefined
4
- warn "`RailsEventStore::MethodNotDefined` has been deprecated. Use `RailsEventStore::InvalidHandler` instead."
5
- InvalidHandler
6
- end
7
- end