rails_event_store 0.28.2 → 0.29.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_event_store/client.rb +22 -4
- data/lib/rails_event_store/middleware.rb +14 -6
- data/lib/rails_event_store/railtie.rb +1 -22
- data/lib/rails_event_store/version.rb +1 -1
- data/rails_event_store.gemspec +4 -5
- metadata +9 -24
- data/Rakefile +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd9e513f596526d177e0c8bd4d83e69cc2e4a9e7a1da997b06476f1627e706b9
|
4
|
+
data.tar.gz: 4f206686458299fd3fbea36de7e958fa78f7d7156b31430372ccf418a92642e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79fe89e91791087fd4882ca33128cdf1bfbb63146b10842534df7fa7cd72c408bdc2b5bdda9847c2c7c4a5eb70d0a7fde670fc39bada18751df3a3b039fa0384
|
7
|
+
data.tar.gz: e25fbdc029a478f45cc1c5de6d4d220712fe0c64ca2a22c79ffc36c1c5bc3453a8e68a5ae98e077440815f4ea5cc7a7f63802003d6b7285a6fe4b53976e9d738
|
@@ -1,16 +1,34 @@
|
|
1
1
|
module RailsEventStore
|
2
2
|
class Client < RubyEventStore::Client
|
3
|
+
attr_reader :request_metadata
|
4
|
+
|
3
5
|
def initialize(repository: RailsEventStoreActiveRecord::EventRepository.new,
|
4
6
|
mapper: RubyEventStore::Mappers::Default.new,
|
5
7
|
event_broker: EventBroker.new(dispatcher: ActiveJobDispatcher.new),
|
8
|
+
request_metadata: default_request_metadata,
|
6
9
|
page_size: PAGE_SIZE)
|
7
|
-
capture_metadata = ->{ Thread.current[:rails_event_store] }
|
8
10
|
super(repository: repository,
|
9
11
|
mapper: mapper,
|
10
12
|
event_broker: event_broker,
|
11
|
-
page_size: page_size
|
12
|
-
|
13
|
+
page_size: page_size)
|
14
|
+
@request_metadata = request_metadata
|
15
|
+
end
|
16
|
+
|
17
|
+
def with_request_metadata(env, &block)
|
18
|
+
with_metadata(request_metadata.call(env)) do
|
19
|
+
block.call
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
23
|
+
private
|
24
|
+
def default_request_metadata
|
25
|
+
->(env) do
|
26
|
+
request = ActionDispatch::Request.new(env)
|
27
|
+
{
|
28
|
+
remote_ip: request.remote_ip,
|
29
|
+
request_id: request.uuid
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
15
33
|
end
|
16
|
-
end
|
34
|
+
end
|
@@ -1,15 +1,23 @@
|
|
1
1
|
module RailsEventStore
|
2
2
|
class Middleware
|
3
|
-
def initialize(app
|
3
|
+
def initialize(app)
|
4
4
|
@app = app
|
5
|
-
@request_metadata_proc = request_metadata_proc
|
6
5
|
end
|
7
6
|
|
8
7
|
def call(env)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
if config.respond_to?(:event_store)
|
9
|
+
config.event_store.with_request_metadata(env) do
|
10
|
+
@app.call(env)
|
11
|
+
end
|
12
|
+
else
|
13
|
+
@app.call(env)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def config
|
20
|
+
Rails.application.config
|
13
21
|
end
|
14
22
|
end
|
15
23
|
end
|
@@ -4,28 +4,7 @@ require 'rails_event_store/middleware'
|
|
4
4
|
module RailsEventStore
|
5
5
|
class Railtie < ::Rails::Railtie
|
6
6
|
initializer 'rails_event_store.middleware' do |rails|
|
7
|
-
rails.middleware.use(::RailsEventStore::Middleware
|
8
|
-
end
|
9
|
-
|
10
|
-
class RailsConfig
|
11
|
-
def initialize(config)
|
12
|
-
@config = config
|
13
|
-
end
|
14
|
-
|
15
|
-
def request_metadata
|
16
|
-
return default_request_metadata unless @config.respond_to?(:rails_event_store)
|
17
|
-
@config.rails_event_store.fetch(:request_metadata, default_request_metadata)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
def default_request_metadata
|
22
|
-
->(env) do
|
23
|
-
request = ActionDispatch::Request.new(env)
|
24
|
-
{ remote_ip: request.remote_ip,
|
25
|
-
request_id: request.uuid,
|
26
|
-
}
|
27
|
-
end
|
28
|
-
end
|
7
|
+
rails.middleware.use(::RailsEventStore::Middleware)
|
29
8
|
end
|
30
9
|
end
|
31
10
|
end
|
data/rails_event_store.gemspec
CHANGED
@@ -29,16 +29,15 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
30
|
spec.add_development_dependency 'rspec', '~> 3.6'
|
31
31
|
spec.add_development_dependency 'rails', '~> 5.2'
|
32
|
-
spec.add_development_dependency 'pry'
|
33
32
|
spec.add_development_dependency 'sqlite3'
|
34
33
|
spec.add_development_dependency 'rack-test'
|
35
34
|
spec.add_development_dependency 'mutant-rspec', '~> 0.8.14'
|
36
35
|
spec.add_development_dependency 'google-protobuf', '~> 3.5.1.2'
|
37
36
|
|
38
|
-
spec.add_dependency 'ruby_event_store', '= 0.
|
39
|
-
spec.add_dependency 'rails_event_store_active_record', '= 0.
|
40
|
-
spec.add_dependency 'aggregate_root', '= 0.
|
41
|
-
spec.add_dependency 'bounded_context', '= 0.
|
37
|
+
spec.add_dependency 'ruby_event_store', '= 0.29.0'
|
38
|
+
spec.add_dependency 'rails_event_store_active_record', '= 0.29.0'
|
39
|
+
spec.add_dependency 'aggregate_root', '= 0.29.0'
|
40
|
+
spec.add_dependency 'bounded_context', '= 0.29.0'
|
42
41
|
spec.add_dependency 'activesupport', '>= 3.0'
|
43
42
|
spec.add_dependency 'activemodel', '>= 3.0'
|
44
43
|
spec.add_dependency 'activejob', '>= 3.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_event_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.29.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arkency
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '5.2'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: sqlite3
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,56 +128,56 @@ dependencies:
|
|
142
128
|
requirements:
|
143
129
|
- - '='
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
131
|
+
version: 0.29.0
|
146
132
|
type: :runtime
|
147
133
|
prerelease: false
|
148
134
|
version_requirements: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
136
|
- - '='
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
138
|
+
version: 0.29.0
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: rails_event_store_active_record
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
143
|
- - '='
|
158
144
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
145
|
+
version: 0.29.0
|
160
146
|
type: :runtime
|
161
147
|
prerelease: false
|
162
148
|
version_requirements: !ruby/object:Gem::Requirement
|
163
149
|
requirements:
|
164
150
|
- - '='
|
165
151
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
152
|
+
version: 0.29.0
|
167
153
|
- !ruby/object:Gem::Dependency
|
168
154
|
name: aggregate_root
|
169
155
|
requirement: !ruby/object:Gem::Requirement
|
170
156
|
requirements:
|
171
157
|
- - '='
|
172
158
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.
|
159
|
+
version: 0.29.0
|
174
160
|
type: :runtime
|
175
161
|
prerelease: false
|
176
162
|
version_requirements: !ruby/object:Gem::Requirement
|
177
163
|
requirements:
|
178
164
|
- - '='
|
179
165
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.
|
166
|
+
version: 0.29.0
|
181
167
|
- !ruby/object:Gem::Dependency
|
182
168
|
name: bounded_context
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|
184
170
|
requirements:
|
185
171
|
- - '='
|
186
172
|
- !ruby/object:Gem::Version
|
187
|
-
version: 0.
|
173
|
+
version: 0.29.0
|
188
174
|
type: :runtime
|
189
175
|
prerelease: false
|
190
176
|
version_requirements: !ruby/object:Gem::Requirement
|
191
177
|
requirements:
|
192
178
|
- - '='
|
193
179
|
- !ruby/object:Gem::Version
|
194
|
-
version: 0.
|
180
|
+
version: 0.29.0
|
195
181
|
- !ruby/object:Gem::Dependency
|
196
182
|
name: activesupport
|
197
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -259,7 +245,6 @@ files:
|
|
259
245
|
- Gemfile
|
260
246
|
- Makefile
|
261
247
|
- README.md
|
262
|
-
- Rakefile
|
263
248
|
- lib/rails_event_store.rb
|
264
249
|
- lib/rails_event_store/active_job_dispatcher.rb
|
265
250
|
- lib/rails_event_store/all.rb
|
data/Rakefile
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'pry'
|
2
|
-
|
3
|
-
EMPTY_DB = 'spec/test.sqlite3'
|
4
|
-
DEV_DB = 'tmp/run.sqlite3'
|
5
|
-
|
6
|
-
task :run do
|
7
|
-
FileUtils.cp(EMPTY_DB, DEV_DB) unless File.exist?(DEV_DB)
|
8
|
-
require 'rails_event_store'
|
9
|
-
RailsEventStoreActiveRecord::Event.establish_connection(
|
10
|
-
:adapter => 'sqlite3',
|
11
|
-
:database => DEV_DB
|
12
|
-
)
|
13
|
-
pry
|
14
|
-
end
|
15
|
-
|
16
|
-
task :clean do
|
17
|
-
FileUtils.rm(DEV_DB) if File.exist?(DEV_DB)
|
18
|
-
end
|
19
|
-
|
20
|
-
task start: [:clean, :run]
|