active_projection 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97dfe755e5611e78daf6c681a76b8469a6802842
|
4
|
+
data.tar.gz: 23edd1fbad4104a3070efaeec338e05f328c204f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14dc5922412d9951353395420268a532927fbc10838e5be356651f14965a87da6ff1f132dba178e52f0d9d276e07f0a77544e02e804fa7b9f814a6dcd703327b
|
7
|
+
data.tar.gz: 345ebedd47f6e3df1ce2746ee421609d4d4385cb10390d9ff95eb8dffd4459ad02c58501fc55048d905c2f0b62ef1f960b46932a449fb8a3ee312a99607bd36e
|
@@ -11,6 +11,7 @@ module ActiveProjection
|
|
11
11
|
|
12
12
|
def start
|
13
13
|
event_connection.start
|
14
|
+
sync_projections
|
14
15
|
listen_for_events
|
15
16
|
request_missing_events
|
16
17
|
event_channel.work_pool.join
|
@@ -18,6 +19,10 @@ module ActiveProjection
|
|
18
19
|
puts 'Catching Interrupt'
|
19
20
|
end
|
20
21
|
|
22
|
+
def sync_projections
|
23
|
+
ProjectionTypeRegistry.sync_projections
|
24
|
+
end
|
25
|
+
|
21
26
|
def listen_for_events
|
22
27
|
subscribe_to event_queue do |delivery_info, properties, body|
|
23
28
|
event_received properties, body
|
@@ -20,6 +20,16 @@ module ActiveProjection
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.sync_projections
|
24
|
+
instance.sync_projections
|
25
|
+
end
|
26
|
+
|
27
|
+
def sync_projections
|
28
|
+
projections.each do |projection|
|
29
|
+
ProjectionRepository.create_or_get(projection.class.name)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
23
33
|
private
|
24
34
|
|
25
35
|
cattr_accessor :registry
|
@@ -20,4 +20,9 @@ describe ActiveProjection::ProjectionTypeRegistry do
|
|
20
20
|
expect_any_instance_of(TestProjection).to receive(:invoke).with(event, headers)
|
21
21
|
ActiveProjection::ProjectionTypeRegistry.process(headers, event)
|
22
22
|
end
|
23
|
+
|
24
|
+
it 'synchronizes the known projections with the db' do
|
25
|
+
expect(ActiveProjection::ProjectionRepository).to receive(:create_or_get).with('TestProjection')
|
26
|
+
ActiveProjection::ProjectionTypeRegistry.sync_projections
|
27
|
+
end
|
23
28
|
end
|
@@ -15,11 +15,15 @@ describe ActiveProjection::ProjectionType do
|
|
15
15
|
def test_event(event, headers)
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def admin__dummy_event(event)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
class TestEvent
|
22
22
|
end
|
23
|
+
module Admin
|
24
|
+
class DummyEvent
|
25
|
+
end
|
26
|
+
end
|
23
27
|
before :each do
|
24
28
|
allow(ActiveProjection::ProjectionTypeRegistry).to receive(:register)
|
25
29
|
TestProjection.send(:include, ActiveProjection::ProjectionType)
|
@@ -64,11 +68,20 @@ describe ActiveProjection::ProjectionType do
|
|
64
68
|
end
|
65
69
|
end
|
66
70
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
71
|
+
describe 'invokes correct handler' do
|
72
|
+
it 'without namespace' do
|
73
|
+
expect(ActiveProjection::ProjectionRepository).to receive(:set_last_id).with(1, 6)
|
74
|
+
expect(@projection).to receive(:test_event)
|
75
|
+
expect(@projection).to_not receive(:admin__dummy_event)
|
76
|
+
@projection.invoke(TestEvent.new, {id: 6})
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'with namespace' do
|
80
|
+
expect(ActiveProjection::ProjectionRepository).to receive(:set_last_id).with(1, 6)
|
81
|
+
expect(@projection).to receive(:admin__dummy_event)
|
82
|
+
expect(@projection).to_not receive(:test_event)
|
83
|
+
@projection.invoke(Admin::DummyEvent.new, {id: 6})
|
84
|
+
end
|
72
85
|
end
|
73
86
|
end
|
74
87
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_projection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Reischuck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_event
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.4.
|
19
|
+
version: 0.4.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.4.
|
26
|
+
version: 0.4.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
195
|
rubyforge_project:
|
196
|
-
rubygems_version: 2.
|
196
|
+
rubygems_version: 2.1.11
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: Projection related stuff (part of rails-disco)
|