rails_event_store 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/CHANGELOG.md +6 -0
- data/Makefile +4 -1
- data/README.md +16 -1
- data/lib/rails_event_store.rb +1 -0
- data/lib/rails_event_store/client.rb +7 -5
- data/lib/rails_event_store/middleware.rb +20 -0
- data/lib/rails_event_store/railtie.rb +31 -0
- data/lib/rails_event_store/version.rb +1 -1
- data/rails_event_store.gemspec +2 -0
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f293f9d8372ff1ebbe6d19452e0a36da254e35d5
|
4
|
+
data.tar.gz: 16d5058e4bf1d193f3915a03463137e2b4a59f87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77c1dc3c5b932dea4fb140c49a1b9e96c3fcd064379547967c7d05b0d0b5dd7e9d2a88fb1a0ed5c0891ad99a1bdecb0b6a39a6ff5582fefa28019dc110de27e3
|
7
|
+
data.tar.gz: b504f349467e50ccaf8a5e7ac9f00f66de6d80f03657da0b6b770e7f79c2c51701a9dd1459537a1b63f40d7cd91752fa4a35ee40e400a0e9592032a322134c08
|
data/.travis.yml
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.1.
|
3
|
+
- 2.1.10
|
4
|
+
- 2.2.5
|
5
|
+
- 2.3.1
|
4
6
|
before_install: gem install bundler
|
5
7
|
gemfile: Gemfile
|
8
|
+
script: make mutate
|
6
9
|
notifications:
|
7
10
|
slack:
|
8
11
|
secure: i/GM4u6oCfgdt9ablmOx4ov3Y9bHJjHabXxWXt+GLRlfW5MDdzwEH0QOx2mveVbit+00rKKqZzBAbEQ1yLo4MLLovHyJvCzoluC10u0MRIR7e8ZlCdlww+IL3JmD8E7G1a/fKEMoKwfLrYUXa5K0oAeKpJ3RwP+tTD+g3KxQfIA=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
### 0.10.0 (30.06.2016)
|
2
|
+
|
3
|
+
* Change: Rails request details in event metadata PR #39
|
4
|
+
* Change: Add dynamic subscriptions (implemented by ruby_event_store 0.9.0) PR #43
|
5
|
+
* Fix: In-memory sqlite3 with schema load over prebaked filesystem blob in testing PR #41
|
6
|
+
|
1
7
|
### 0.9.0 (24.06.2016)
|
2
8
|
|
3
9
|
* Change: ruby_event_store updated to 0.9.0 (Call instead of handle_event)
|
data/Makefile
CHANGED
@@ -8,10 +8,13 @@ test: ## Run tests
|
|
8
8
|
@echo "Running basic tests - beware: this won't guarantee build pass"
|
9
9
|
@bundle exec rspec
|
10
10
|
|
11
|
+
mutate: test ## Run mutation tests
|
12
|
+
@echo "Running mutation tests - only 100% free mutation will be accepted"
|
13
|
+
@bundle exec mutant --include lib --require rails_event_store --use rspec "RailsEventStore*" --expected-coverage 452/612
|
14
|
+
|
11
15
|
.PHONY: help
|
12
16
|
|
13
17
|
help:
|
14
18
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
15
19
|
|
16
20
|
.DEFAULT_GOAL := help
|
17
|
-
|
data/README.md
CHANGED
@@ -11,12 +11,27 @@ Default storage is events repository based on Active Record (provided by separat
|
|
11
11
|
|
12
12
|
# Documentation
|
13
13
|
|
14
|
-
All documentation and sample codes are available at [http://railseventstore.arkency.com](http://railseventstore.arkency.com)
|
14
|
+
All documentation and sample codes are available at [http://railseventstore.arkency.com](http://railseventstore.arkency.com). If you'd like to contribute by writing or maintaining docs, they're stored in the `gh-pages` branch in this repository.
|
15
|
+
|
15
16
|
|
16
17
|
# Contributing
|
17
18
|
|
18
19
|
Check the contribution guide on [CONTRIBUTING.md](https://github.com/arkency/rails_event_store/blob/master/CONTRIBUTING.md)
|
19
20
|
|
21
|
+
We're aiming for 100% mutation coverage in this project.
|
22
|
+
Read the reasoning:
|
23
|
+
|
24
|
+
[Why I want to introduce mutation testing to the rails_event_store gem](http://blog.arkency.com/2015/04/why-i-want-to-introduce-mutation-testing-to-the-rails-event-store-gem/)
|
25
|
+
|
26
|
+
[Mutation testing and continuous integration](http://blog.arkency.com/2015/05/mutation-testing-and-continuous-integration/)
|
27
|
+
|
28
|
+
In practice, it means that we run `make mutate` as part of the CI process. As long as we don't have 100%, there's a hardcoded value we expect from the mutation coverage.
|
29
|
+
|
30
|
+
Whenever you fix a bug or add a new feature, we require that the coverage doesn't go down.
|
31
|
+
|
32
|
+
However, even if it goes up, you need to go the `Makefile` and apply the new expected coverage. We call this technique "raising the coverage bar". The goal here is to raise the bar so that the better coverage is maintained for later changes. The new value should be the Kills/Mutations number in your last `make mutate` output.
|
33
|
+
|
34
|
+
|
20
35
|
## About
|
21
36
|
|
22
37
|
<img src="http://arkency.com/images/arkency.png" alt="Arkency" width="20%" align="left" />
|
data/lib/rails_event_store.rb
CHANGED
@@ -10,7 +10,9 @@ module RailsEventStore
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def publish_event(event, stream_name = GLOBAL_STREAM, expected_version = :any)
|
13
|
-
|
13
|
+
captured_metadata = Thread.current[:rails_event_store] || {}
|
14
|
+
enriched_event = event.class.new(event_id: event.event_id, metadata: captured_metadata.merge(event.metadata), **event.data)
|
15
|
+
event_store.publish_event(enriched_event, stream_name, expected_version)
|
14
16
|
end
|
15
17
|
|
16
18
|
def append_to_stream(event, stream_name = GLOBAL_STREAM, expected_version = :any)
|
@@ -48,12 +50,12 @@ module RailsEventStore
|
|
48
50
|
event_store.read_all_streams_backward(start, count)
|
49
51
|
end
|
50
52
|
|
51
|
-
def subscribe(subscriber, event_types)
|
52
|
-
event_store.subscribe(subscriber, event_types)
|
53
|
+
def subscribe(subscriber, event_types, &proc)
|
54
|
+
event_store.subscribe(subscriber, event_types, &proc)
|
53
55
|
end
|
54
56
|
|
55
|
-
def subscribe_to_all_events(subscriber)
|
56
|
-
event_store.subscribe_to_all_events(subscriber)
|
57
|
+
def subscribe_to_all_events(subscriber, &proc)
|
58
|
+
event_store.subscribe_to_all_events(subscriber, &proc)
|
57
59
|
end
|
58
60
|
|
59
61
|
private
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RailsEventStore
|
2
|
+
class Middleware
|
3
|
+
def initialize(app, request_metadata)
|
4
|
+
@app = app
|
5
|
+
@request_metadata = request_metadata
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
dup._call(env)
|
10
|
+
end
|
11
|
+
|
12
|
+
def _call(env)
|
13
|
+
Thread.current[:rails_event_store] = @request_metadata.(env)
|
14
|
+
@app.call(env)
|
15
|
+
ensure
|
16
|
+
Thread.current[:rails_event_store] = nil
|
17
|
+
body.close if body && body.respond_to?(:close) && $!
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rails_event_store/middleware'
|
2
|
+
|
3
|
+
module RailsEventStore
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
initializer 'rails_event_store.middleware' do |rails|
|
6
|
+
rails.middleware.use(::RailsEventStore::Middleware, RailsConfig.new(rails.config).request_metadata)
|
7
|
+
end
|
8
|
+
|
9
|
+
class RailsConfig
|
10
|
+
def initialize(config)
|
11
|
+
@config = config
|
12
|
+
end
|
13
|
+
|
14
|
+
def request_metadata
|
15
|
+
return default_request_metadata unless @config.respond_to?(:rails_event_store)
|
16
|
+
@config.rails_event_store.fetch(:request_metadata, default_request_metadata)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def default_request_metadata
|
21
|
+
->(env) do
|
22
|
+
request = ActionDispatch::Request.new(env)
|
23
|
+
{ remote_ip: request.remote_ip,
|
24
|
+
request_id: request.uuid,
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/rails_event_store.gemspec
CHANGED
@@ -25,11 +25,13 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'rspec'
|
26
26
|
spec.add_development_dependency 'rails', '~> 4.2'
|
27
27
|
spec.add_development_dependency 'sqlite3'
|
28
|
+
spec.add_development_dependency 'rack-test'
|
28
29
|
|
29
30
|
spec.add_dependency 'ruby_event_store', '~> 0.9.0'
|
30
31
|
spec.add_dependency 'rails_event_store_active_record', '~> 0.6.3'
|
31
32
|
spec.add_dependency 'aggregate_root', '~> 0.3.1'
|
32
33
|
spec.add_dependency 'activesupport', '>= 3.0'
|
33
34
|
spec.add_dependency 'activemodel', '>= 3.0'
|
35
|
+
spec.add_development_dependency 'mutant-rspec', '~> 0.8'
|
34
36
|
|
35
37
|
end
|
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.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arkency
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rack-test
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: ruby_event_store
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +178,20 @@ dependencies:
|
|
164
178
|
- - ">="
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '3.0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: mutant-rspec
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0.8'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0.8'
|
167
195
|
description: Implementation of Event Store in Ruby
|
168
196
|
email:
|
169
197
|
- dev@arkency.com
|
@@ -183,6 +211,8 @@ files:
|
|
183
211
|
- lib/rails_event_store.rb
|
184
212
|
- lib/rails_event_store/client.rb
|
185
213
|
- lib/rails_event_store/constants.rb
|
214
|
+
- lib/rails_event_store/middleware.rb
|
215
|
+
- lib/rails_event_store/railtie.rb
|
186
216
|
- lib/rails_event_store/version.rb
|
187
217
|
- rails_event_store.gemspec
|
188
218
|
- tmp/.keep
|