eventus 0.3.9 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,7 @@ module Eventus
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def commit(events)
|
15
|
+
return if events.empty?
|
15
16
|
seqs = events.map{|e| e['sequence']}
|
16
17
|
doc = {
|
17
18
|
'_id' => "#{events[0]['sid']}_#{seqs.min}",
|
@@ -25,7 +26,7 @@ module Eventus
|
|
25
26
|
future = @commits.find_one({sid:doc['sid'], max:{:$gte => doc['min']}})
|
26
27
|
raise Eventus::ConcurrencyError if future
|
27
28
|
begin
|
28
|
-
@commits.insert(doc,
|
29
|
+
@commits.insert(doc, w: 2)
|
29
30
|
rescue ::Mongo::OperationFailure => e
|
30
31
|
raise Eventus::ConcurrencyError if e.error_code == 11000
|
31
32
|
end
|
data/lib/eventus/stream.rb
CHANGED
@@ -26,6 +26,7 @@ module Eventus
|
|
26
26
|
e['sequence'] = i
|
27
27
|
end
|
28
28
|
Eventus::logger.debug "Committing #{@uncommitted_events.length} events to #{@id}"
|
29
|
+
return if @uncommitted_events.empty?
|
29
30
|
payload = @persistence.commit @uncommitted_events
|
30
31
|
load_events @uncommitted_events
|
31
32
|
@dispatcher.dispatch(payload) if @dispatcher
|
data/lib/eventus/version.rb
CHANGED
@@ -8,11 +8,11 @@ describe Eventus::Persistence::KyotoCabinet do
|
|
8
8
|
@persistence = Eventus::Persistence::KyotoCabinet.new
|
9
9
|
end
|
10
10
|
|
11
|
-
it "should pack keys" do
|
11
|
+
it "should not pack keys" do
|
12
12
|
1000.times do
|
13
13
|
key = uuid.generate(:compact)
|
14
14
|
packed = persistence.pack_hex(key)
|
15
|
-
packed.
|
15
|
+
packed.should == key
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -77,24 +77,8 @@ describe Eventus::Persistence::Mongo do
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
let(:persistence) { Eventus::Persistence::KyotoCabinet.new(:path => '%', :serializer => serializer) }
|
83
|
-
|
84
|
-
it "should use serializer" do
|
85
|
-
input = {:name => 'event'}
|
86
|
-
ser = "serialized!!"
|
87
|
-
id = uuid.generate :compact
|
88
|
-
commit = create_commit(id, 1, input)
|
89
|
-
|
90
|
-
serializer.should_receive(:serialize).with(commit[0]).and_return(ser)
|
91
|
-
serializer.should_receive(:deserialize).with(ser).and_return(input)
|
92
|
-
|
93
|
-
|
94
|
-
persistence.commit commit
|
95
|
-
result = persistence.load id
|
96
|
-
result[0].should == input
|
97
|
-
end
|
80
|
+
it 'should return nil if there are no events' do
|
81
|
+
persistence.commit([]).should be_nil
|
98
82
|
end
|
99
83
|
end
|
100
84
|
|
data/spec/stream_spec.rb
CHANGED
@@ -18,6 +18,12 @@ describe Eventus::Stream do
|
|
18
18
|
stream.uncommitted_events.should be_empty
|
19
19
|
end
|
20
20
|
|
21
|
+
it "should not commit to persistence if no uncommited events" do
|
22
|
+
persistence.should_not_receive(:commit)
|
23
|
+
stream.uncommitted_events.clear
|
24
|
+
stream.commit
|
25
|
+
end
|
26
|
+
|
21
27
|
describe "when events available from persistence" do
|
22
28
|
before do
|
23
29
|
persistence.should_receive(:load).and_return([stub, stub])
|
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.
|
4
|
+
version: 0.4.0
|
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:
|
12
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: An Event Store
|
15
15
|
email:
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project: eventus
|
68
|
-
rubygems_version: 1.8.
|
68
|
+
rubygems_version: 1.8.23
|
69
69
|
signing_key:
|
70
70
|
specification_version: 3
|
71
71
|
summary: Event Store
|