euston-eventstore 1.1.0-java → 1.2.0-java
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.
- data/euston-eventstore.gemspec +9 -7
- data/lib/euston-eventstore/command_message.rb +26 -0
- data/lib/euston-eventstore/commit.rb +7 -2
- data/lib/euston-eventstore/optimistic_event_stream.rb +11 -5
- data/lib/euston-eventstore/persistence/mongodb/mongo_command_message.rb +32 -0
- data/lib/euston-eventstore/persistence/mongodb/mongo_commit.rb +11 -3
- data/lib/euston-eventstore/persistence/mongodb/mongo_config.rb +2 -6
- data/lib/euston-eventstore/persistence/mongodb/mongo_event_message.rb +6 -5
- data/lib/euston-eventstore/persistence/mongodb/mongo_persistence_engine.rb +40 -27
- data/lib/euston-eventstore/persistence/mongodb/mongo_persistence_factory.rb +1 -1
- data/lib/euston-eventstore/persistence/mongodb/mongo_snapshot.rb +4 -4
- data/lib/euston-eventstore/persistence/mongodb/mongo_stream_head.rb +2 -2
- data/lib/euston-eventstore/repository.rb +2 -1
- data/lib/euston-eventstore/version.rb +1 -1
- data/lib/euston-eventstore.rb +2 -0
- data/spec/spec_helper.rb +2 -3
- metadata +166 -171
data/euston-eventstore.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'euston-eventstore'
|
3
|
-
s.version = '1.
|
4
|
-
s.date = '2011-10-
|
3
|
+
s.version = '1.2.0'
|
4
|
+
s.date = '2011-10-12'
|
5
5
|
s.platform = RUBY_PLATFORM.to_s == 'java' ? 'java' : Gem::Platform::RUBY
|
6
6
|
s.authors = ['Lee Henson', 'Guy Boertje']
|
7
7
|
s.email = ['lee.m.henson@gmail.com', 'guyboertje@gmail.com']
|
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
Rakefile
|
15
15
|
euston-eventstore.gemspec
|
16
16
|
lib/euston-eventstore.rb
|
17
|
+
lib/euston-eventstore/command_message.rb
|
17
18
|
lib/euston-eventstore/commit.rb
|
18
19
|
lib/euston-eventstore/constants.rb
|
19
20
|
lib/euston-eventstore/dispatcher/asynchronous_dispatcher.rb
|
@@ -23,6 +24,7 @@ Gem::Specification.new do |s|
|
|
23
24
|
lib/euston-eventstore/event_message.rb
|
24
25
|
lib/euston-eventstore/optimistic_event_store.rb
|
25
26
|
lib/euston-eventstore/optimistic_event_stream.rb
|
27
|
+
lib/euston-eventstore/persistence/mongodb/mongo_command_message.rb
|
26
28
|
lib/euston-eventstore/persistence/mongodb/mongo_commit.rb
|
27
29
|
lib/euston-eventstore/persistence/mongodb/mongo_commit_id.rb
|
28
30
|
lib/euston-eventstore/persistence/mongodb/mongo_config.rb
|
@@ -51,17 +53,17 @@ Gem::Specification.new do |s|
|
|
51
53
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
52
54
|
|
53
55
|
s.add_dependency 'activesupport', '~> 3.0.9'
|
54
|
-
s.add_dependency 'euston', '~> 1.
|
56
|
+
s.add_dependency 'euston', '~> 1.2.0'
|
55
57
|
s.add_dependency 'hash-keys', '~> 1.0.0'
|
56
58
|
|
57
59
|
if RUBY_PLATFORM.to_s == 'java'
|
58
60
|
s.add_dependency 'json-jruby', '~> 1.5.0'
|
59
|
-
s.add_dependency 'jmongo', '~> 1.1.
|
61
|
+
s.add_dependency 'jmongo', '~> 1.1.1'
|
60
62
|
else
|
61
|
-
s.add_dependency 'bson', '~> 1.
|
62
|
-
s.add_dependency 'bson_ext', '~> 1.
|
63
|
+
s.add_dependency 'bson', '~> 1.4.0'
|
64
|
+
s.add_dependency 'bson_ext', '~> 1.4.0'
|
63
65
|
s.add_dependency 'json', '~> 1.5.0'
|
64
|
-
s.add_dependency 'mongo', '~> 1.
|
66
|
+
s.add_dependency 'mongo', '~> 1.4.0'
|
65
67
|
s.add_dependency 'uuid', '~> 2.3.0'
|
66
68
|
end
|
67
69
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Euston
|
2
|
+
module EventStore
|
3
|
+
# Represents a single element in a stream of commands.
|
4
|
+
class CommandMessage
|
5
|
+
|
6
|
+
def initialize arg = nil
|
7
|
+
if arg.is_a?(Hash) && (arg.keys & ['body','headers']).size == 2
|
8
|
+
@body, @headers = arg.values_at('body','headers')
|
9
|
+
else
|
10
|
+
@headers = {}
|
11
|
+
@body = arg
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_hash
|
16
|
+
{ :headers => @headers, :body => @body }
|
17
|
+
end
|
18
|
+
|
19
|
+
# Gets the metadata which provides additional, unstructured information about this command.
|
20
|
+
attr_reader :headers
|
21
|
+
|
22
|
+
# Gets or sets the actual comman body.
|
23
|
+
attr_reader :body
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -11,7 +11,8 @@ module Euston
|
|
11
11
|
:commit_sequence => 1,
|
12
12
|
:commit_timestamp => Time.now.utc,
|
13
13
|
:headers => OpenStruct.new,
|
14
|
-
:events => []
|
14
|
+
:events => [],
|
15
|
+
:commands => []
|
15
16
|
}
|
16
17
|
values = defaults.merge hash
|
17
18
|
defaults.keys.each { |key| instance_variable_set "@#{key}", values[key] }
|
@@ -25,7 +26,8 @@ module Euston
|
|
25
26
|
:commit_sequence => commit_sequence,
|
26
27
|
:commit_timestamp => commit_timestamp,
|
27
28
|
:headers => headers.is_a?(OpenStruct) ? headers.instance_variable_get(:@table) : headers,
|
28
|
-
:events => events
|
29
|
+
:events => events,
|
30
|
+
:commands => commands
|
29
31
|
}
|
30
32
|
end
|
31
33
|
# Gets the value which uniquely identifies the stream to which the commit belongs.
|
@@ -49,6 +51,9 @@ module Euston
|
|
49
51
|
# Gets the collection of event messages to be committed as a single unit.
|
50
52
|
attr_reader :events
|
51
53
|
|
54
|
+
# Gets the collection of command messages to be committed as a single unit.
|
55
|
+
attr_reader :commands
|
56
|
+
|
52
57
|
def ==(other)
|
53
58
|
(other.is_a? Commit) && (@stream_id == other.stream_id) && (@commit_id == other.commit_id)
|
54
59
|
end
|
@@ -5,6 +5,7 @@ module Euston
|
|
5
5
|
@persistence = options[:persistence]
|
6
6
|
@committed_events = []
|
7
7
|
@committed_headers = {}
|
8
|
+
@uncommitted_commands = []
|
8
9
|
@uncommitted_events = []
|
9
10
|
@uncommitted_headers = {}
|
10
11
|
@commit_sequence = 0
|
@@ -31,13 +32,17 @@ module Euston
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
|
-
attr_reader :stream_id, :stream_revision, :commit_sequence, :committed_events, :committed_headers, :uncommitted_events, :uncommitted_headers
|
35
|
+
attr_reader :stream_id, :stream_revision, :commit_sequence, :committed_events, :committed_headers, :uncommitted_commands, :uncommitted_events, :uncommitted_headers
|
35
36
|
|
36
|
-
def <<(
|
37
|
-
|
37
|
+
def <<(message)
|
38
|
+
return if message.nil? || message.body.nil?
|
39
|
+
|
40
|
+
@uncommitted_commands << message if message.is_a? CommandMessage
|
41
|
+
@uncommitted_events << message if message.is_a? EventMessage
|
38
42
|
end
|
39
43
|
|
40
44
|
def clear_changes
|
45
|
+
@uncommitted_commands = []
|
41
46
|
@uncommitted_events = []
|
42
47
|
@uncommitted_headers = {}
|
43
48
|
end
|
@@ -66,11 +71,12 @@ module Euston
|
|
66
71
|
:commit_sequence => commit_sequence + 1,
|
67
72
|
:commit_timestamp => Time.now.utc,
|
68
73
|
:headers => uncommitted_headers,
|
69
|
-
:events => uncommitted_events
|
74
|
+
:events => uncommitted_events,
|
75
|
+
:commands => uncommitted_commands
|
70
76
|
end
|
71
77
|
|
72
78
|
def has_changes
|
73
|
-
!uncommitted_events.empty?
|
79
|
+
!uncommitted_commands.empty? || !uncommitted_events.empty?
|
74
80
|
end
|
75
81
|
|
76
82
|
def persist_changes(commit_id)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Euston
|
2
|
+
module EventStore
|
3
|
+
module Persistence
|
4
|
+
module Mongodb
|
5
|
+
module MongoCommandMessage
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def from_hash hash
|
10
|
+
hash.recursive_symbolize_keys!
|
11
|
+
|
12
|
+
message = CommandMessage.new hash[:body]
|
13
|
+
message.instance_variable_set :@headers, hash[:headers]
|
14
|
+
message
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_hash
|
19
|
+
{
|
20
|
+
:headers => headers,
|
21
|
+
:body => body.to_hash.recursive_stringify_symbol_values!
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class CommandMessage
|
29
|
+
include Persistence::Mongodb::MongoCommandMessage
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -3,7 +3,7 @@ module Euston
|
|
3
3
|
module Persistence
|
4
4
|
module Mongodb
|
5
5
|
module MongoCommit
|
6
|
-
extend
|
6
|
+
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
included do
|
9
9
|
alias_method :original_initialize, :initialize
|
@@ -18,8 +18,10 @@ module Euston
|
|
18
18
|
|
19
19
|
id = hash['_id']
|
20
20
|
events = hash['events'].sort_by { |e| e["stream_revision"] }.to_a
|
21
|
+
commands = hash['commands'] || []
|
21
22
|
stream_revision = events.last['stream_revision']
|
22
|
-
events = events.map { |e|
|
23
|
+
events = events.map { |e| MongoEventMessage.from_hash e['payload'] }
|
24
|
+
commands = commands.map { |c| MongoCommandMessage.from_hash c }
|
23
25
|
|
24
26
|
Euston::EventStore::Commit.new :stream_id => id['stream_id'],
|
25
27
|
:stream_revision => stream_revision,
|
@@ -27,7 +29,8 @@ module Euston
|
|
27
29
|
:commit_sequence => id['commit_sequence'],
|
28
30
|
:commit_timestamp => hash['commit_timestamp'],
|
29
31
|
:headers => hash['headers'].recursive_symbolize_keys!,
|
30
|
-
:events => events
|
32
|
+
:events => events,
|
33
|
+
:commands => commands
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
@@ -45,6 +48,7 @@ module Euston
|
|
45
48
|
hash.delete :commit_sequence
|
46
49
|
hash[:dispatched] ||= false
|
47
50
|
hash[:events] = hash[:events].map { |e| e.to_hash }
|
51
|
+
hash[:commands] = hash[:commands].map { |c| c.to_hash }
|
48
52
|
hash[:commit_timestamp] = hash[:commit_timestamp].to_f
|
49
53
|
hash
|
50
54
|
end
|
@@ -60,6 +64,10 @@ module Euston
|
|
60
64
|
event_hash
|
61
65
|
end
|
62
66
|
|
67
|
+
hash[:commands] = commands.map do |c|
|
68
|
+
c.to_hash
|
69
|
+
end
|
70
|
+
|
63
71
|
hash[:commit_timestamp_for_humans] = Time.at(hash[:commit_timestamp]).utc
|
64
72
|
|
65
73
|
hash
|
@@ -8,14 +8,10 @@ module Euston
|
|
8
8
|
include ::Singleton
|
9
9
|
|
10
10
|
def uri
|
11
|
-
@uri ||= 'mongodb://0.0.0.0:27017
|
11
|
+
@uri ||= 'mongodb://0.0.0.0:27017/?safe=true;fsync=true;w=1;'
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
@options ||= { :safe => true, :fsync => true, :journal => true }
|
16
|
-
end
|
17
|
-
|
18
|
-
attr_writer :uri, :options
|
14
|
+
attr_writer :uri
|
19
15
|
attr_accessor :database, :logger
|
20
16
|
end
|
21
17
|
end
|
@@ -7,17 +7,18 @@ module Euston
|
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def from_hash(hash)
|
10
|
-
|
11
|
-
|
12
|
-
message.
|
10
|
+
hash.recursive_symbolize_keys!
|
11
|
+
|
12
|
+
message = EventMessage.new hash[:body]
|
13
|
+
message.instance_variable_set :@headers, hash[:headers]
|
13
14
|
message
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
18
|
def to_hash
|
18
19
|
{
|
19
|
-
:headers
|
20
|
-
:body
|
20
|
+
:headers => headers,
|
21
|
+
:body => body.to_hash.recursive_stringify_symbol_values!
|
21
22
|
}
|
22
23
|
end
|
23
24
|
end
|
@@ -22,23 +22,16 @@ module Euston
|
|
22
22
|
doc = { 'headers' => mongo_snapshot[:headers],
|
23
23
|
'payload' => mongo_snapshot[:payload] }.merge(id)
|
24
24
|
|
25
|
-
|
26
|
-
persisted_snapshots.update id, doc, :upsert => true, :safe => true
|
25
|
+
persisted_snapshots.update id, doc, :upsert => true
|
27
26
|
|
28
27
|
id = { '_id' => snapshot.stream_id }
|
29
28
|
|
30
|
-
|
31
|
-
if defined?(JMongo)
|
32
|
-
stream_head = MongoStreamHead.from_hash persisted_stream_heads.find(id).to_a.first
|
33
|
-
else
|
34
|
-
stream_head = MongoStreamHead.from_hash persisted_stream_heads.find_one(id)
|
35
|
-
end
|
29
|
+
stream_head = MongoStreamHead.from_hash persisted_stream_heads.find_one(id)
|
36
30
|
|
37
31
|
modifiers = { '$set' => { 'snapshot_revision' => snapshot.stream_revision,
|
38
32
|
'unsnapshotted' => stream_head.head_revision - snapshot.stream_revision } }
|
39
33
|
|
40
|
-
|
41
|
-
persisted_stream_heads.update id, modifiers, :safe => true
|
34
|
+
persisted_stream_heads.update id, modifiers
|
42
35
|
return true
|
43
36
|
rescue Mongo::OperationFailure
|
44
37
|
return false
|
@@ -50,19 +43,13 @@ module Euston
|
|
50
43
|
commit = attempt.to_mongo_commit
|
51
44
|
|
52
45
|
begin
|
53
|
-
|
54
|
-
persisted_commits.insert commit, :safe => true
|
46
|
+
persisted_commits.insert commit
|
55
47
|
|
56
48
|
update_stream_head_async attempt.stream_id, attempt.stream_revision, attempt.events.length
|
57
49
|
rescue Mongo::OperationFailure, NativeException => e
|
58
50
|
raise(Euston::EventStore::StorageError, e.message, e.backtrace) unless e.message.include? CONCURRENCY_EXCEPTION
|
59
51
|
|
60
|
-
|
61
|
-
if defined?(JMongo)
|
62
|
-
committed = persisted_commits.find(attempt.to_id_query).to_a.first
|
63
|
-
else
|
64
|
-
committed = persisted_commits.find_one(attempt.to_id_query)
|
65
|
-
end
|
52
|
+
committed = persisted_commits.find_one(attempt.to_id_query)
|
66
53
|
|
67
54
|
raise Euston::EventStore::DuplicateCommitError if !committed.nil? && committed['commit_id'] == attempt.commit_id
|
68
55
|
raise Euston::EventStore::ConcurrencyError
|
@@ -82,7 +69,7 @@ module Euston
|
|
82
69
|
order = [ 'events.stream_revision', Mongo::ASCENDING ]
|
83
70
|
end
|
84
71
|
|
85
|
-
persisted_commits.find(query
|
72
|
+
persisted_commits.find(query, :sort => order).to_a.map { |hash| MongoCommit.from_hash hash }
|
86
73
|
end
|
87
74
|
end
|
88
75
|
|
@@ -92,7 +79,7 @@ module Euston
|
|
92
79
|
'$lte' => { 'stream_id' => stream_id, 'stream_revision' => max_revision } } }
|
93
80
|
order = [ '_id', Mongo::DESCENDING ]
|
94
81
|
|
95
|
-
persisted_snapshots.find(query
|
82
|
+
persisted_snapshots.find(query, :sort => order, :limit => 1).map { |hash| MongoSnapshot::from_hash hash }.first
|
96
83
|
end
|
97
84
|
end
|
98
85
|
|
@@ -101,22 +88,25 @@ module Euston
|
|
101
88
|
query = { 'unsnapshotted' => { '$gte' => max_threshold } }
|
102
89
|
order = [ 'unsnapshotted', Mongo::DESCENDING ]
|
103
90
|
|
104
|
-
persisted_stream_heads.find(query
|
91
|
+
persisted_stream_heads.find(query, :sort => order).map { |hash| MongoStreamHead.from_hash hash }
|
105
92
|
end
|
106
93
|
end
|
107
94
|
|
108
|
-
def get_undispatched_commits
|
95
|
+
def get_undispatched_commits component_id = nil
|
109
96
|
try_mongo do
|
110
97
|
query = { 'dispatched' => false }
|
98
|
+
query['component_id'] = component_id unless component_id.nil?
|
99
|
+
|
111
100
|
order = [ 'commit_timestamp', Mongo::ASCENDING ]
|
112
101
|
|
113
|
-
persisted_commits.find(query
|
102
|
+
persisted_commits.find(query, :sort => order, :batch_size => 100).to_a.map { |hash| MongoCommit.from_hash hash }
|
114
103
|
end
|
115
104
|
end
|
116
105
|
|
117
106
|
def init
|
118
107
|
try_mongo do
|
119
108
|
persisted_commits.ensure_index [ ['dispatched', Mongo::ASCENDING],
|
109
|
+
['component_id', Mongo::ASCENDING],
|
120
110
|
['commit_timestamp', Mongo::ASCENDING] ], :unique => false, :name => 'dispatched_index'
|
121
111
|
|
122
112
|
persisted_commits.ensure_index [ ['_id.stream_id', Mongo::ASCENDING],
|
@@ -130,9 +120,33 @@ module Euston
|
|
130
120
|
end
|
131
121
|
|
132
122
|
def mark_commit_as_dispatched(commit)
|
123
|
+
mark_commits_as_dispatched [commit]
|
124
|
+
end
|
125
|
+
|
126
|
+
def mark_commits_as_dispatched(commits)
|
127
|
+
return if commits.empty?
|
128
|
+
|
129
|
+
try_mongo do
|
130
|
+
id_queries = commits.map { |c| c.to_id_query }
|
131
|
+
query = { '$or' => id_queries }
|
132
|
+
|
133
|
+
persisted_commits.update query, { '$set' => { 'dispatched' => true }, '$unset' => { 'component_id' => 1 } }, :multi => true
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def take_ownership_of_undispatched_commits component_id
|
133
138
|
try_mongo do
|
134
|
-
|
135
|
-
|
139
|
+
new_commits_eligible_for_dispatch = { 'component_id' => nil,
|
140
|
+
'dispatched' => false }
|
141
|
+
|
142
|
+
commits_stuck_in_other_components = { 'component_id' => { '$ne' => nil } ,
|
143
|
+
'dispatched' => false,
|
144
|
+
'commit_timestamp' => Time.now.to_f - 60 }
|
145
|
+
|
146
|
+
query = { '$or' => [ new_commits_eligible_for_dispatch, commits_stuck_in_other_components ] }
|
147
|
+
doc = { '$set' => { 'component_id' => component_id } }
|
148
|
+
|
149
|
+
persisted_commits.update query, doc, :multi => true
|
136
150
|
end
|
137
151
|
end
|
138
152
|
|
@@ -162,12 +176,11 @@ module Euston
|
|
162
176
|
|
163
177
|
def update_stream_head_async(stream_id, stream_revision, events_count)
|
164
178
|
Thread.fork do
|
165
|
-
# jmongo doesn't currently honour the safe mode on the connection, so we have to specify safe here
|
166
179
|
id = { '_id' => stream_id }
|
167
180
|
doc = { '$set' => { 'head_revision' => stream_revision },
|
168
181
|
'$inc' => { 'snapshot_revision' => 0, 'unsnapshotted' => events_count } }
|
169
182
|
|
170
|
-
persisted_stream_heads.update id, doc, :upsert => true
|
183
|
+
persisted_stream_heads.update id, doc, :upsert => true
|
171
184
|
end
|
172
185
|
end
|
173
186
|
|
@@ -17,7 +17,7 @@ module Euston
|
|
17
17
|
class MongoPersistenceFactory
|
18
18
|
def self.build
|
19
19
|
config = Config.instance
|
20
|
-
options =
|
20
|
+
options = {}
|
21
21
|
options.merge!(:logger => config.logger) unless config.logger.nil?
|
22
22
|
|
23
23
|
@connection ||= Mongo::Connection.from_uri config.uri, options
|
@@ -11,10 +11,10 @@ module Euston
|
|
11
11
|
|
12
12
|
id = hash['_id']
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
Snapshot.new id['stream_id'],
|
15
|
+
id['stream_revision'],
|
16
|
+
hash['payload'].recursive__symbolize__keys!,
|
17
|
+
hash['headers'].recursive__symbolize__keys!
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -3,12 +3,12 @@ module Euston
|
|
3
3
|
module Persistence
|
4
4
|
module Mongodb
|
5
5
|
module MongoStreamHead
|
6
|
-
extend
|
6
|
+
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def from_hash hash
|
10
10
|
return nil if hash.nil?
|
11
|
-
|
11
|
+
StreamHead.new hash['_id'], hash['head_revision'], hash['snapshot_revision']
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -10,7 +10,8 @@ module Euston
|
|
10
10
|
|
11
11
|
def save aggregate
|
12
12
|
stream = event_store.open_stream :stream_id => aggregate.aggregate_id
|
13
|
-
aggregate.uncommitted_events.each { |e| stream <<
|
13
|
+
aggregate.uncommitted_events.each { |e| stream << EventStore::EventMessage.new(e.to_hash.stringify__keys) }
|
14
|
+
aggregate.uncommitted_commands.each { |c| stream << EventStore::CommandMessage.new(c.to_hash.stringify__keys) }
|
14
15
|
stream.uncommitted_headers[:aggregate_type] = aggregate.class.to_s
|
15
16
|
stream.commit_changes Euston.uuid.generate
|
16
17
|
end
|
data/lib/euston-eventstore.rb
CHANGED
@@ -4,6 +4,7 @@ require 'hash-keys'
|
|
4
4
|
require 'euston-eventstore/commit'
|
5
5
|
require 'euston-eventstore/constants'
|
6
6
|
require 'euston-eventstore/errors'
|
7
|
+
require 'euston-eventstore/command_message'
|
7
8
|
require 'euston-eventstore/event_message'
|
8
9
|
require 'euston-eventstore/optimistic_event_store'
|
9
10
|
require 'euston-eventstore/optimistic_event_stream'
|
@@ -17,6 +18,7 @@ require 'euston-eventstore/persistence/stream_head'
|
|
17
18
|
require 'euston-eventstore/persistence/mongodb/mongo_commit'
|
18
19
|
require 'euston-eventstore/persistence/mongodb/mongo_commit_id'
|
19
20
|
require 'euston-eventstore/persistence/mongodb/mongo_config'
|
21
|
+
require 'euston-eventstore/persistence/mongodb/mongo_command_message'
|
20
22
|
require 'euston-eventstore/persistence/mongodb/mongo_event_message'
|
21
23
|
require 'euston-eventstore/persistence/mongodb/mongo_persistence_engine'
|
22
24
|
require 'euston-eventstore/persistence/mongodb/mongo_persistence_factory'
|
data/spec/spec_helper.rb
CHANGED
@@ -28,14 +28,13 @@ require 'support/array_enumeration_counter'
|
|
28
28
|
|
29
29
|
mongo_config = Euston::EventStore::Persistence::Mongodb::Config.instance
|
30
30
|
mongo_config.database = 'event_store_tests'
|
31
|
-
mongo_config.options = { :safe => true, :fsync => true, :journal => true } #, :logger => Logger.new(STDOUT)
|
32
31
|
|
33
32
|
RSpec.configure do |config|
|
34
33
|
config.fail_fast = true
|
35
34
|
|
36
35
|
config.before :each do
|
37
|
-
connection = Mongo::Connection.from_uri
|
38
|
-
db = connection.db
|
36
|
+
connection = Mongo::Connection.from_uri mongo_config.uri
|
37
|
+
db = connection.db mongo_config.database
|
39
38
|
db.collections.select { |c| c.name !~ /system/ }.each { |c| db.drop_collection c.name }
|
40
39
|
end
|
41
40
|
end
|
metadata
CHANGED
@@ -1,190 +1,185 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: euston-eventstore
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 1.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.2.0
|
6
6
|
platform: java
|
7
|
-
authors:
|
8
|
-
|
9
|
-
|
10
|
-
autorequire:
|
7
|
+
authors:
|
8
|
+
- Lee Henson
|
9
|
+
- Guy Boertje
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
version_requirements: *id009
|
13
|
+
date: 2011-10-12 00:00:00.000000000 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: activesupport
|
18
|
+
version_requirements: &2210 !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.9
|
23
|
+
none: false
|
24
|
+
requirement: *2210
|
25
|
+
prerelease: false
|
26
|
+
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: euston
|
29
|
+
version_requirements: &2228 !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.0
|
34
|
+
none: false
|
35
|
+
requirement: *2228
|
36
|
+
prerelease: false
|
37
|
+
type: :runtime
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: hash-keys
|
40
|
+
version_requirements: &2244 !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.0.0
|
45
|
+
none: false
|
46
|
+
requirement: *2244
|
47
|
+
prerelease: false
|
48
|
+
type: :runtime
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: json-jruby
|
51
|
+
version_requirements: &2260 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.5.0
|
56
|
+
none: false
|
57
|
+
requirement: *2260
|
58
|
+
prerelease: false
|
59
|
+
type: :runtime
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: jmongo
|
62
|
+
version_requirements: &2276 !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.1.1
|
67
|
+
none: false
|
68
|
+
requirement: *2276
|
69
|
+
prerelease: false
|
70
|
+
type: :runtime
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: awesome_print
|
73
|
+
version_requirements: &2292 !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.4.0
|
78
|
+
none: false
|
79
|
+
requirement: *2292
|
80
|
+
prerelease: false
|
81
|
+
type: :development
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: fuubar
|
84
|
+
version_requirements: &2310 !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.0.0
|
89
|
+
none: false
|
90
|
+
requirement: *2310
|
91
|
+
prerelease: false
|
92
|
+
type: :development
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rake
|
95
|
+
version_requirements: &2326 !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ~>
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 0.9.2
|
100
|
+
none: false
|
101
|
+
requirement: *2326
|
102
|
+
prerelease: false
|
103
|
+
type: :development
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: rspec
|
106
|
+
version_requirements: &2342 !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.6.0
|
111
|
+
none: false
|
112
|
+
requirement: *2342
|
113
|
+
prerelease: false
|
114
|
+
type: :development
|
116
115
|
description: Ruby port for Jonathan Oliver's EventStore. See https://github.com/joliver/EventStore for details.
|
117
|
-
email:
|
118
|
-
|
119
|
-
|
116
|
+
email:
|
117
|
+
- lee.m.henson@gmail.com
|
118
|
+
- guyboertje@gmail.com
|
120
119
|
executables: []
|
121
|
-
|
122
120
|
extensions: []
|
123
|
-
|
124
121
|
extra_rdoc_files: []
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
122
|
+
files:
|
123
|
+
- Gemfile
|
124
|
+
- Rakefile
|
125
|
+
- euston-eventstore.gemspec
|
126
|
+
- lib/euston-eventstore.rb
|
127
|
+
- lib/euston-eventstore/command_message.rb
|
128
|
+
- lib/euston-eventstore/commit.rb
|
129
|
+
- lib/euston-eventstore/constants.rb
|
130
|
+
- lib/euston-eventstore/dispatcher/asynchronous_dispatcher.rb
|
131
|
+
- lib/euston-eventstore/dispatcher/null_dispatcher.rb
|
132
|
+
- lib/euston-eventstore/dispatcher/synchronous_dispatcher.rb
|
133
|
+
- lib/euston-eventstore/errors.rb
|
134
|
+
- lib/euston-eventstore/event_message.rb
|
135
|
+
- lib/euston-eventstore/optimistic_event_store.rb
|
136
|
+
- lib/euston-eventstore/optimistic_event_stream.rb
|
137
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_command_message.rb
|
138
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_commit.rb
|
139
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_commit_id.rb
|
140
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_config.rb
|
141
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_event_message.rb
|
142
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_persistence_engine.rb
|
143
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_persistence_factory.rb
|
144
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_snapshot.rb
|
145
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_stream_head.rb
|
146
|
+
- lib/euston-eventstore/persistence/stream_head.rb
|
147
|
+
- lib/euston-eventstore/repository.rb
|
148
|
+
- lib/euston-eventstore/snapshot.rb
|
149
|
+
- lib/euston-eventstore/snapshot_stream_pair.rb
|
150
|
+
- lib/euston-eventstore/version.rb
|
151
|
+
- spec/event_store/dispatcher/asynchronous_dispatcher_spec.rb
|
152
|
+
- spec/event_store/dispatcher/synchronous_dispatcher_spec.rb
|
153
|
+
- spec/event_store/optimistic_event_store_spec.rb
|
154
|
+
- spec/event_store/optimistic_event_stream_spec.rb
|
155
|
+
- spec/event_store/persistence/mongodb_spec.rb
|
156
|
+
- spec/event_store/serialization/simple_message.rb
|
157
|
+
- spec/spec_helper.rb
|
158
|
+
- spec/support/array_enumeration_counter.rb
|
161
159
|
has_rdoc: true
|
162
160
|
homepage: http://github.com/leemhenson/euston-eventstore
|
163
161
|
licenses: []
|
164
|
-
|
165
|
-
post_install_message:
|
162
|
+
post_install_message:
|
166
163
|
rdoc_options: []
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ! '>='
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
171
|
none: false
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
172
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ! '>='
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
177
|
none: false
|
178
|
-
requirements:
|
179
|
-
- - ">="
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
version: "0"
|
182
178
|
requirements: []
|
183
|
-
|
184
|
-
rubyforge_project:
|
179
|
+
rubyforge_project:
|
185
180
|
rubygems_version: 1.5.1
|
186
|
-
signing_key:
|
181
|
+
signing_key:
|
187
182
|
specification_version: 3
|
188
183
|
summary: Event store for use with Euston.
|
189
184
|
test_files: []
|
190
|
-
|
185
|
+
...
|