eventus 0.3.6 → 0.3.7
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.
@@ -29,6 +29,7 @@ module Eventus
|
|
29
29
|
rescue ::Mongo::OperationFailure => e
|
30
30
|
raise Eventus::ConcurrencyError if e.error_code == 11000
|
31
31
|
end
|
32
|
+
doc
|
32
33
|
end
|
33
34
|
|
34
35
|
def load(id, min = nil)
|
@@ -48,16 +49,16 @@ module Eventus
|
|
48
49
|
.sort_by{|e| e['sequence']}
|
49
50
|
end
|
50
51
|
|
51
|
-
def
|
52
|
-
commits = @commits.find(dispatched:
|
52
|
+
def load_undispatched_commits
|
53
|
+
commits = @commits.find(dispatched:false).to_a
|
53
54
|
if commits.length > 0
|
54
55
|
Eventus.logger.info "#{commits.length} undispatched commits loaded"
|
55
56
|
end
|
56
57
|
commits
|
57
58
|
end
|
58
59
|
|
59
|
-
def
|
60
|
-
Eventus.logger.debug "Marking #{commit_id} dispatched"
|
60
|
+
def mark_commit_dispatched(commit_id)
|
61
|
+
Eventus.logger.debug "Marking commit #{commit_id} dispatched"
|
61
62
|
@commits.update({_id: commit_id}, {dispatched: true})
|
62
63
|
end
|
63
64
|
|
data/lib/eventus/stream.rb
CHANGED
@@ -26,9 +26,9 @@ module Eventus
|
|
26
26
|
e['sequence'] = i
|
27
27
|
end
|
28
28
|
Eventus::logger.debug "Committing #{@uncommitted_events.length} events to #{@id}"
|
29
|
-
@persistence.commit @uncommitted_events
|
29
|
+
payload = @persistence.commit @uncommitted_events
|
30
30
|
load_events @uncommitted_events
|
31
|
-
@dispatcher.dispatch
|
31
|
+
@dispatcher.dispatch(payload) if @dispatcher
|
32
32
|
@uncommitted_events.clear
|
33
33
|
rescue ConcurrencyError => e
|
34
34
|
Eventus.logger.info "ConcurrencyError, loading new events for: #{id}"
|
data/lib/eventus/version.rb
CHANGED
@@ -5,7 +5,7 @@ describe Eventus::Persistence::Mongo do
|
|
5
5
|
let(:uuid) { UUID.new }
|
6
6
|
|
7
7
|
before(:all) do
|
8
|
-
@persistence = Eventus::Persistence::Mongo.new(
|
8
|
+
@persistence = Eventus::Persistence::Mongo.new(MONGO_URI)
|
9
9
|
@persistence.db.collection('eventus_commits').drop
|
10
10
|
end
|
11
11
|
|
@@ -50,13 +50,13 @@ describe Eventus::Persistence::Mongo do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should load undispatched events" do
|
53
|
-
result = persistence.
|
53
|
+
result = persistence.load_undispatched_commits
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should mark an event as dispatched" do
|
57
|
-
result = persistence.
|
58
|
-
persistence.
|
59
|
-
persistence.
|
57
|
+
result = persistence.load_undispatched_commits[0]
|
58
|
+
persistence.mark_commit_dispatched(result['_id'])
|
59
|
+
persistence.load_undispatched_commits.include?(result).should be_false
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should throw concurrency exception if the same event number is added" do
|
data/spec/spec_helper.rb
CHANGED
data/spec/stream_spec.rb
CHANGED
@@ -44,8 +44,9 @@ describe Eventus::Stream do
|
|
44
44
|
|
45
45
|
describe "when committed" do
|
46
46
|
before do
|
47
|
-
|
48
|
-
|
47
|
+
payload = {:truck => 'money'}
|
48
|
+
persistence.should_receive(:commit).and_return(payload)
|
49
|
+
dispatcher.should_receive(:dispatch).with(payload)
|
49
50
|
stream.commit
|
50
51
|
end
|
51
52
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: An Event Store
|
15
15
|
email:
|