rails_event_store 0.30.0 → 0.31.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: a3d4e0009af4124fcd60998861a6a397048887b9e5b3ea57dcf5356b2fd3c2c0
4
- data.tar.gz: f62347ca2d8bf35e365647b09720c6410cb0096b1c512f11176c77f09cc7a808
3
+ metadata.gz: b76f46be4f7d613e250ca140d1da214c785132518e52cd0001e9282aaa3f037d
4
+ data.tar.gz: 2b44dd20664323a79d47b57ede062ba202f674ea4196ce15e5d51f4f4cae6cb0
5
5
  SHA512:
6
- metadata.gz: 59fd5ddb62bf2fb5e4db8c28771a1888b63bb6b2bbf3e16b0fc703d50a6e2956e65218eb0d6eb5fd3df417b8d49dc0c04a8eb8296a8e686ce32ee1b3721cfce0
7
- data.tar.gz: 8b2720a1bd23f634d5ae5475cad76e39c2a5845f73e99b4059421818af5b2bf34f278186bf807fdb615b146581055e10ab950c6079364262564eb5d789c0cb55
6
+ metadata.gz: 726f8eed5f15a7697e6c628b0e2a051f9d76497d7488700a4178a65cc712c97ad124c3beb838bca3b58aab7365d9a6658fe8b49162d4b03526d1be4fbc5d49fb
7
+ data.tar.gz: f8214c5acfc208ad8d840c558a44d59ac41296099b9ca513d05db68d5ab87f4c4be6e26bb39ba27202b7881aa0610f69be97bfd7d90cd994812fdb41a6da35c3
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ gem 'rails_event_store_active_record', path: '../rails_event_store_active_record
6
6
  gem 'aggregate_root', path: '../aggregate_root'
7
7
  gem 'bounded_context', path: '../bounded_context'
8
8
  gem 'protobuf_nested_struct'
9
+ gem 'sidekiq'
9
10
 
10
11
  if v = ENV['RAILS_VERSION']
11
12
  gem 'rails', v
@@ -1,71 +1,19 @@
1
1
  require 'active_job'
2
2
 
3
3
  module RailsEventStore
4
- module AsyncProxyStrategy
5
- class AfterCommit
6
- def call(klass, event)
7
- if ActiveRecord::Base.connection.transaction_open?
8
- ActiveRecord::Base.
9
- connection.
10
- current_transaction.
11
- add_record(AsyncRecord.new(klass, event))
12
- else
13
- klass.perform_later(YAML.dump(event))
14
- end
15
- end
16
-
17
- private
18
- class AsyncRecord
19
- def initialize(klass, event)
20
- @klass = klass
21
- @event = event
22
- end
23
-
24
- def committed!
25
- @klass.perform_later(YAML.dump(@event))
26
- end
27
-
28
- def rolledback!(*)
29
- end
30
-
31
- def before_committed!
32
- end
33
-
34
- def add_to_transaction
35
- AfterCommit.new.call(@klass, @event)
36
- end
37
- end
38
- end
39
-
40
- class Inline
41
- def call(klass, event)
42
- klass.perform_later(YAML.dump(event))
43
- end
44
- end
45
- end
46
-
47
- class ActiveJobDispatcher < RubyEventStore::PubSub::Dispatcher
4
+ class ActiveJobDispatcher < RubyEventStore::AsyncDispatcher
48
5
  def initialize(proxy_strategy: AsyncProxyStrategy::Inline.new)
49
- @async_proxy_strategy = proxy_strategy
6
+ super(proxy_strategy: proxy_strategy, scheduler: ActiveJobScheduler.new)
50
7
  end
51
8
 
52
- def call(subscriber, event)
53
- if async_handler?(subscriber)
54
- @async_proxy_strategy.call(subscriber, event)
55
- else
56
- super
9
+ class ActiveJobScheduler
10
+ def call(klass, serialized_event)
11
+ klass.perform_later(serialized_event.to_h)
57
12
  end
58
- end
59
13
 
60
- def verify(subscriber)
61
- super unless async_handler?(subscriber)
62
- end
63
-
64
- private
65
-
66
- def async_handler?(klass)
67
- Class === klass && klass < ActiveJob::Base
14
+ def async_handler?(klass)
15
+ Class === klass && klass < ActiveJob::Base
16
+ end
68
17
  end
69
-
70
18
  end
71
- end
19
+ end
@@ -1,23 +1,29 @@
1
1
  require 'ruby_event_store'
2
+ require 'rails_event_store/async_proxy_strategy'
2
3
  require 'rails_event_store/active_job_dispatcher'
4
+ require 'rails_event_store/async_handler_helpers'
5
+ require 'rails_event_store/link_by_metadata'
3
6
  require 'rails_event_store/client'
4
7
  require 'rails_event_store/version'
5
8
  require 'rails_event_store/railtie'
6
9
  require 'rails_event_store/deprecations'
7
10
 
8
11
  module RailsEventStore
9
- Event = RubyEventStore::Event
10
- InMemoryRepository = RubyEventStore::InMemoryRepository
11
- EventBroker = RubyEventStore::PubSub::Broker
12
- Projection = RubyEventStore::Projection
13
- WrongExpectedEventVersion = RubyEventStore::WrongExpectedEventVersion
14
- InvalidExpectedVersion = RubyEventStore::InvalidExpectedVersion
15
- IncorrectStreamData = RubyEventStore::IncorrectStreamData
16
- EventNotFound = RubyEventStore::EventNotFound
17
- SubscriberNotExist = RubyEventStore::SubscriberNotExist
18
- InvalidHandler = RubyEventStore::InvalidHandler
19
- InvalidPageStart = RubyEventStore::InvalidPageStart
20
- InvalidPageSize = RubyEventStore::InvalidPageSize
21
- GLOBAL_STREAM = RubyEventStore::GLOBAL_STREAM
22
- PAGE_SIZE = RubyEventStore::PAGE_SIZE
23
- end
12
+ Event = RubyEventStore::Event
13
+ InMemoryRepository = RubyEventStore::InMemoryRepository
14
+ Subscriptions = RubyEventStore::PubSub::Subscriptions
15
+ Projection = RubyEventStore::Projection
16
+ WrongExpectedEventVersion = RubyEventStore::WrongExpectedEventVersion
17
+ InvalidExpectedVersion = RubyEventStore::InvalidExpectedVersion
18
+ IncorrectStreamData = RubyEventStore::IncorrectStreamData
19
+ EventNotFound = RubyEventStore::EventNotFound
20
+ SubscriberNotExist = RubyEventStore::SubscriberNotExist
21
+ InvalidHandler = RubyEventStore::InvalidHandler
22
+ InvalidPageStart = RubyEventStore::InvalidPageStart
23
+ InvalidPageSize = RubyEventStore::InvalidPageSize
24
+ CorrelatedCommands = RubyEventStore::CorrelatedCommands
25
+ GLOBAL_STREAM = RubyEventStore::GLOBAL_STREAM
26
+ PAGE_SIZE = RubyEventStore::PAGE_SIZE
27
+ AsyncProxyStrategy::Inline = RubyEventStore::AsyncProxyStrategy::Inline
28
+ AsyncDispatcher = RubyEventStore::AsyncDispatcher
29
+ end
@@ -0,0 +1,20 @@
1
+ module RailsEventStore
2
+
3
+ module AsyncHandler
4
+ def perform(payload)
5
+ super(Rails.configuration.event_store.deserialize(payload))
6
+ end
7
+ end
8
+
9
+ module CorrelatedHandler
10
+ def perform(event)
11
+ Rails.configuration.event_store.with_metadata(
12
+ correlation_id: event.metadata[:correlation_id] || event.event_id,
13
+ causation_id: event.event_id
14
+ ) do
15
+ super
16
+ end
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,39 @@
1
+ module RailsEventStore
2
+ module AsyncProxyStrategy
3
+ class AfterCommit
4
+ def call(schedule_proc)
5
+ if ActiveRecord::Base.connection.transaction_open?
6
+ ActiveRecord::Base.
7
+ connection.
8
+ current_transaction.
9
+ add_record(AsyncRecord.new(schedule_proc))
10
+ else
11
+ schedule_proc.call
12
+ end
13
+ end
14
+
15
+ private
16
+ class AsyncRecord
17
+ def initialize(schedule_proc)
18
+ @schedule_proc = schedule_proc
19
+ end
20
+
21
+ def committed!
22
+ schedule_proc.call
23
+ end
24
+
25
+ def rolledback!(*)
26
+ end
27
+
28
+ def before_committed!
29
+ end
30
+
31
+ def add_to_transaction
32
+ AfterCommit.new.call(schedule_proc)
33
+ end
34
+
35
+ attr_reader :schedule_proc
36
+ end
37
+ end
38
+ end
39
+ end
@@ -4,12 +4,14 @@ module RailsEventStore
4
4
 
5
5
  def initialize(repository: RailsEventStoreActiveRecord::EventRepository.new,
6
6
  mapper: RubyEventStore::Mappers::Default.new,
7
- event_broker: EventBroker.new(dispatcher: ActiveJobDispatcher.new),
7
+ subscriptions: RubyEventStore::PubSub::Subscriptions.new,
8
+ dispatcher: ActiveJobDispatcher.new,
8
9
  request_metadata: default_request_metadata,
9
10
  page_size: PAGE_SIZE)
10
11
  super(repository: repository,
11
12
  mapper: mapper,
12
- event_broker: event_broker,
13
+ subscriptions: subscriptions,
14
+ dispatcher: dispatcher,
13
15
  page_size: page_size)
14
16
  @request_metadata = request_metadata
15
17
  end
@@ -0,0 +1,27 @@
1
+ module RailsEventStore
2
+
3
+ class LinkByMetadata < RubyEventStore::LinkByMetadata
4
+ def initialize(event_store: Rails.configuration.event_store, key:, prefix: nil)
5
+ super(event_store: event_store, key: key, prefix: prefix)
6
+ end
7
+ end
8
+
9
+ class LinkByCorrelationId < RubyEventStore::LinkByCorrelationId
10
+ def initialize(event_store: Rails.configuration.event_store, prefix: nil)
11
+ super(event_store: event_store, prefix: prefix)
12
+ end
13
+ end
14
+
15
+ class LinkByCausationId < RubyEventStore::LinkByCausationId
16
+ def initialize(event_store: Rails.configuration.event_store, prefix: nil)
17
+ super(event_store: event_store, prefix: prefix)
18
+ end
19
+ end
20
+
21
+ class LinkByEventType < RubyEventStore::LinkByEventType
22
+ def initialize(event_store: Rails.configuration.event_store, prefix: nil)
23
+ super(event_store: event_store, prefix: prefix)
24
+ end
25
+ end
26
+
27
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsEventStore
2
- VERSION = "0.30.0"
2
+ VERSION = "0.31.0"
3
3
  end
@@ -33,11 +33,12 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'rack-test'
34
34
  spec.add_development_dependency 'mutant-rspec', '~> 0.8.14'
35
35
  spec.add_development_dependency 'google-protobuf', '~> 3.5.1.2'
36
+ spec.add_development_dependency 'pry'
36
37
 
37
- spec.add_dependency 'ruby_event_store', '= 0.30.0'
38
- spec.add_dependency 'rails_event_store_active_record', '= 0.30.0'
39
- spec.add_dependency 'aggregate_root', '= 0.30.0'
40
- spec.add_dependency 'bounded_context', '= 0.30.0'
38
+ spec.add_dependency 'ruby_event_store', '= 0.31.0'
39
+ spec.add_dependency 'rails_event_store_active_record', '= 0.31.0'
40
+ spec.add_dependency 'aggregate_root', '= 0.31.0'
41
+ spec.add_dependency 'bounded_context', '= 0.31.0'
41
42
  spec.add_dependency 'activesupport', '>= 3.0'
42
43
  spec.add_dependency 'activemodel', '>= 3.0'
43
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.30.0
4
+ version: 0.31.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-05-31 00:00:00.000000000 Z
11
+ date: 2018-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,62 +122,76 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 3.5.1.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: ruby_event_store
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - '='
130
144
  - !ruby/object:Gem::Version
131
- version: 0.30.0
145
+ version: 0.31.0
132
146
  type: :runtime
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - '='
137
151
  - !ruby/object:Gem::Version
138
- version: 0.30.0
152
+ version: 0.31.0
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rails_event_store_active_record
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - '='
144
158
  - !ruby/object:Gem::Version
145
- version: 0.30.0
159
+ version: 0.31.0
146
160
  type: :runtime
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - '='
151
165
  - !ruby/object:Gem::Version
152
- version: 0.30.0
166
+ version: 0.31.0
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: aggregate_root
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - '='
158
172
  - !ruby/object:Gem::Version
159
- version: 0.30.0
173
+ version: 0.31.0
160
174
  type: :runtime
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - '='
165
179
  - !ruby/object:Gem::Version
166
- version: 0.30.0
180
+ version: 0.31.0
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: bounded_context
169
183
  requirement: !ruby/object:Gem::Requirement
170
184
  requirements:
171
185
  - - '='
172
186
  - !ruby/object:Gem::Version
173
- version: 0.30.0
187
+ version: 0.31.0
174
188
  type: :runtime
175
189
  prerelease: false
176
190
  version_requirements: !ruby/object:Gem::Requirement
177
191
  requirements:
178
192
  - - '='
179
193
  - !ruby/object:Gem::Version
180
- version: 0.30.0
194
+ version: 0.31.0
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: activesupport
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -248,8 +262,11 @@ files:
248
262
  - lib/rails_event_store.rb
249
263
  - lib/rails_event_store/active_job_dispatcher.rb
250
264
  - lib/rails_event_store/all.rb
265
+ - lib/rails_event_store/async_handler_helpers.rb
266
+ - lib/rails_event_store/async_proxy_strategy.rb
251
267
  - lib/rails_event_store/client.rb
252
268
  - lib/rails_event_store/deprecations.rb
269
+ - lib/rails_event_store/link_by_metadata.rb
253
270
  - lib/rails_event_store/middleware.rb
254
271
  - lib/rails_event_store/railtie.rb
255
272
  - lib/rails_event_store/version.rb