euston-eventstore 1.0.4-java → 1.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Rakefile +2 -3
- data/euston-eventstore.gemspec +11 -6
- data/lib/euston-eventstore/optimistic_event_store.rb +8 -1
- data/lib/euston-eventstore/optimistic_event_stream.rb +3 -1
- data/lib/euston-eventstore/persistence/mongodb/mongo_commit.rb +20 -20
- data/lib/euston-eventstore/persistence/mongodb/mongo_config.rb +4 -8
- data/lib/euston-eventstore/persistence/mongodb/mongo_persistence_engine.rb +28 -16
- data/lib/euston-eventstore/persistence/mongodb/mongo_persistence_factory.rb +5 -5
- data/lib/euston-eventstore/persistence/mongodb/mongo_snapshot.rb +5 -1
- data/lib/euston-eventstore/persistence/mongodb/mongo_stream_head.rb +2 -1
- data/lib/euston-eventstore/persistence/stream_head.rb +1 -1
- data/lib/euston-eventstore/repository.rb +19 -0
- data/lib/euston-eventstore/snapshot.rb +6 -2
- data/lib/euston-eventstore/snapshot_stream_pair.rb +17 -0
- data/lib/euston-eventstore/version.rb +1 -1
- data/lib/euston-eventstore.rb +21 -2
- data/spec/event_store/dispatcher/asynchronous_dispatcher_spec.rb +1 -3
- data/spec/event_store/dispatcher/synchronous_dispatcher_spec.rb +0 -2
- data/spec/event_store/optimistic_event_store_spec.rb +0 -2
- data/spec/event_store/optimistic_event_stream_spec.rb +0 -2
- data/spec/event_store/persistence/mongodb_spec.rb +2 -3
- data/spec/spec_helper.rb +3 -1
- metadata +173 -161
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -65,11 +65,10 @@ end
|
|
65
65
|
#
|
66
66
|
#############################################################################
|
67
67
|
|
68
|
-
default_rspec_opts = %w[--colour --format Fuubar]
|
69
|
-
|
70
68
|
desc "Run all examples"
|
71
69
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
72
|
-
t.rspec_opts =
|
70
|
+
t.rspec_opts = ['-r ./spec/spec_helper.rb', '--colour', '--format Fuubar']
|
71
|
+
t.pattern = 'spec/**/*_spec.rb'
|
73
72
|
end
|
74
73
|
|
75
74
|
#############################################################################
|
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.0
|
4
|
-
s.date = '2011-
|
3
|
+
s.version = '1.1.0'
|
4
|
+
s.date = '2011-10-03'
|
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']
|
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = 'http://github.com/leemhenson/euston-eventstore'
|
11
11
|
# = MANIFEST =
|
12
12
|
s.files = %w[
|
13
|
+
Gemfile
|
13
14
|
Rakefile
|
14
15
|
euston-eventstore.gemspec
|
15
16
|
lib/euston-eventstore.rb
|
@@ -31,7 +32,9 @@ Gem::Specification.new do |s|
|
|
31
32
|
lib/euston-eventstore/persistence/mongodb/mongo_snapshot.rb
|
32
33
|
lib/euston-eventstore/persistence/mongodb/mongo_stream_head.rb
|
33
34
|
lib/euston-eventstore/persistence/stream_head.rb
|
35
|
+
lib/euston-eventstore/repository.rb
|
34
36
|
lib/euston-eventstore/snapshot.rb
|
37
|
+
lib/euston-eventstore/snapshot_stream_pair.rb
|
35
38
|
lib/euston-eventstore/version.rb
|
36
39
|
spec/event_store/dispatcher/asynchronous_dispatcher_spec.rb
|
37
40
|
spec/event_store/dispatcher/synchronous_dispatcher_spec.rb
|
@@ -48,20 +51,22 @@ Gem::Specification.new do |s|
|
|
48
51
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
49
52
|
|
50
53
|
s.add_dependency 'activesupport', '~> 3.0.9'
|
54
|
+
s.add_dependency 'euston', '~> 1.1.0'
|
51
55
|
s.add_dependency 'hash-keys', '~> 1.0.0'
|
52
|
-
s.add_dependency 'require_all', '~> 1.2.0'
|
53
|
-
s.add_dependency 'uuid', '~> 2.3.0'
|
54
56
|
|
55
57
|
if RUBY_PLATFORM.to_s == 'java'
|
56
58
|
s.add_dependency 'json-jruby', '~> 1.5.0'
|
57
|
-
s.add_dependency 'jmongo', '~> 1.
|
59
|
+
s.add_dependency 'jmongo', '~> 1.1.0'
|
58
60
|
else
|
61
|
+
s.add_dependency 'bson', '~> 1.3.1'
|
59
62
|
s.add_dependency 'bson_ext', '~> 1.3.1'
|
60
63
|
s.add_dependency 'json', '~> 1.5.0'
|
61
64
|
s.add_dependency 'mongo', '~> 1.3.1'
|
65
|
+
s.add_dependency 'uuid', '~> 2.3.0'
|
62
66
|
end
|
63
67
|
|
64
68
|
s.add_development_dependency 'awesome_print', '~> 0.4.0'
|
65
69
|
s.add_development_dependency 'fuubar', '~> 0.0.0'
|
70
|
+
s.add_development_dependency 'rake', '~> 0.9.2'
|
66
71
|
s.add_development_dependency 'rspec', '~> 2.6.0'
|
67
|
-
end
|
72
|
+
end
|
@@ -31,7 +31,7 @@ module Euston
|
|
31
31
|
:max_revision => max_revision).to_enum
|
32
32
|
end
|
33
33
|
|
34
|
-
def get_snapshot(stream_id, max_revision)
|
34
|
+
def get_snapshot(stream_id, max_revision = 0)
|
35
35
|
@persistence.get_snapshot stream_id, validate_max_revision(max_revision)
|
36
36
|
end
|
37
37
|
|
@@ -39,6 +39,13 @@ module Euston
|
|
39
39
|
@persistence.get_streams_to_snapshot max_threshold
|
40
40
|
end
|
41
41
|
|
42
|
+
def get_snapshot_stream_pair stream_id
|
43
|
+
snapshot = get_snapshot stream_id
|
44
|
+
stream = open_stream :stream_id => stream_id, :snapshot => snapshot
|
45
|
+
|
46
|
+
SnapshotStreamPair.new snapshot, stream
|
47
|
+
end
|
48
|
+
|
42
49
|
def open_stream(options)
|
43
50
|
options = { :stream_id => nil,
|
44
51
|
:min_revision => 0,
|
@@ -4,6 +4,7 @@ module Euston
|
|
4
4
|
def initialize(options)
|
5
5
|
@persistence = options[:persistence]
|
6
6
|
@committed_events = []
|
7
|
+
@committed_headers = {}
|
7
8
|
@uncommitted_events = []
|
8
9
|
@uncommitted_headers = {}
|
9
10
|
@commit_sequence = 0
|
@@ -30,7 +31,7 @@ module Euston
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
attr_reader :stream_id, :stream_revision, :commit_sequence, :committed_events, :uncommitted_events, :uncommitted_headers
|
34
|
+
attr_reader :stream_id, :stream_revision, :commit_sequence, :committed_events, :committed_headers, :uncommitted_events, :uncommitted_headers
|
34
35
|
|
35
36
|
def <<(event)
|
36
37
|
@uncommitted_events << event unless event.nil? || event.body.nil?
|
@@ -84,6 +85,7 @@ module Euston
|
|
84
85
|
commits.each do |commit|
|
85
86
|
@identifiers << commit.commit_id
|
86
87
|
@commit_sequence = commit.commit_sequence
|
88
|
+
@committed_headers.merge! commit.to_hash[:headers] || {}
|
87
89
|
|
88
90
|
current_revision = commit.stream_revision - commit.events.length + 1
|
89
91
|
|
@@ -8,6 +8,8 @@ module Euston
|
|
8
8
|
included do
|
9
9
|
alias_method :original_initialize, :initialize
|
10
10
|
alias_method :initialize, :mongo_initialize
|
11
|
+
alias_method :original_to_hash, :to_hash
|
12
|
+
alias_method :to_hash, :to_mongo_hash
|
11
13
|
end
|
12
14
|
|
13
15
|
class << self
|
@@ -36,33 +38,31 @@ module Euston
|
|
36
38
|
|
37
39
|
attr_reader :dispatched
|
38
40
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
def to_mongo_hash
|
42
|
+
hash = original_to_hash
|
43
|
+
hash[:_id] = { :stream_id => hash.delete(:stream_id), :commit_sequence => hash.delete(:commit_sequence) }
|
44
|
+
hash.delete :stream_revision
|
45
|
+
hash.delete :commit_sequence
|
46
|
+
hash[:dispatched] ||= false
|
47
|
+
hash[:events] = hash[:events].map { |e| e.to_hash }
|
48
|
+
hash[:commit_timestamp] = hash[:commit_timestamp].to_f
|
49
|
+
hash
|
48
50
|
end
|
49
51
|
|
50
52
|
def to_mongo_commit
|
51
53
|
mongo_stream_revision = stream_revision - (events.length - 1)
|
52
|
-
|
53
|
-
|
54
|
+
|
55
|
+
hash = to_mongo_hash
|
56
|
+
|
57
|
+
hash[:events] = events.map do |e|
|
58
|
+
event_hash = { :stream_revision => mongo_stream_revision, :payload => e.to_hash }
|
54
59
|
mongo_stream_revision += 1
|
55
|
-
|
60
|
+
event_hash
|
56
61
|
end
|
57
62
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
:commit_timestamp => commit_timestamp.to_f,
|
62
|
-
:headers => headers,
|
63
|
-
:events => mongo_events,
|
64
|
-
:dispatched => false
|
65
|
-
}
|
63
|
+
hash[:commit_timestamp_for_humans] = Time.at(hash[:commit_timestamp]).utc
|
64
|
+
|
65
|
+
hash
|
66
66
|
end
|
67
67
|
|
68
68
|
def to_id_query
|
@@ -7,19 +7,15 @@ module Euston
|
|
7
7
|
class Config
|
8
8
|
include ::Singleton
|
9
9
|
|
10
|
-
def
|
11
|
-
@
|
12
|
-
end
|
13
|
-
|
14
|
-
def port
|
15
|
-
@port ||= 27017
|
10
|
+
def uri
|
11
|
+
@uri ||= 'mongodb://0.0.0.0:27017/'
|
16
12
|
end
|
17
13
|
|
18
14
|
def options
|
19
|
-
@options ||= { :safe =>
|
15
|
+
@options ||= { :safe => true, :fsync => true, :journal => true }
|
20
16
|
end
|
21
17
|
|
22
|
-
attr_writer :
|
18
|
+
attr_writer :uri, :options
|
23
19
|
attr_accessor :database, :logger
|
24
20
|
end
|
25
21
|
end
|
@@ -7,9 +7,9 @@ module Euston
|
|
7
7
|
@store = store
|
8
8
|
|
9
9
|
collection_names = store.collection_names
|
10
|
-
store.create_collection 'commits'
|
11
|
-
store.create_collection '
|
12
|
-
store.create_collection 'streams'
|
10
|
+
store.create_collection 'commits' unless collection_names.include? 'commits'
|
11
|
+
store.create_collection 'snapshots' unless collection_names.include? 'snapshots'
|
12
|
+
store.create_collection 'streams' unless collection_names.include? 'streams'
|
13
13
|
end
|
14
14
|
|
15
15
|
def add_snapshot(snapshot)
|
@@ -17,20 +17,28 @@ module Euston
|
|
17
17
|
|
18
18
|
begin
|
19
19
|
mongo_snapshot = snapshot.is_a?(Hash) ? snapshot : snapshot.to_hash
|
20
|
-
id = { '_id' => mongo_snapshot[:_id] }
|
21
20
|
|
22
|
-
|
21
|
+
id = { '_id' => mongo_snapshot[:_id] }
|
22
|
+
doc = { 'headers' => mongo_snapshot[:headers],
|
23
|
+
'payload' => mongo_snapshot[:payload] }.merge(id)
|
24
|
+
|
25
|
+
# jmongo doesn't currently honour the safe mode on the connection, so we have to specify safe here
|
26
|
+
persisted_snapshots.update id, doc, :upsert => true, :safe => true
|
27
|
+
|
28
|
+
id = { '_id' => snapshot.stream_id }
|
23
29
|
|
24
30
|
# jmongo's find_one is broken
|
25
31
|
if defined?(JMongo)
|
26
|
-
stream_head = MongoStreamHead.from_hash persisted_stream_heads.find(
|
32
|
+
stream_head = MongoStreamHead.from_hash persisted_stream_heads.find(id).to_a.first
|
27
33
|
else
|
28
|
-
stream_head = MongoStreamHead.from_hash persisted_stream_heads.find_one(
|
34
|
+
stream_head = MongoStreamHead.from_hash persisted_stream_heads.find_one(id)
|
29
35
|
end
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
modifiers = { '$set' => { 'snapshot_revision' => snapshot.stream_revision,
|
38
|
+
'unsnapshotted' => stream_head.head_revision - snapshot.stream_revision } }
|
39
|
+
|
40
|
+
# jmongo doesn't currently honour the safe mode on the connection, so we have to specify safe here
|
41
|
+
persisted_stream_heads.update id, modifiers, :safe => true
|
34
42
|
return true
|
35
43
|
rescue Mongo::OperationFailure
|
36
44
|
return false
|
@@ -42,8 +50,9 @@ module Euston
|
|
42
50
|
commit = attempt.to_mongo_commit
|
43
51
|
|
44
52
|
begin
|
45
|
-
#
|
53
|
+
# jmongo doesn't currently honour the safe mode on the connection, so we have to specify safe here
|
46
54
|
persisted_commits.insert commit, :safe => true
|
55
|
+
|
47
56
|
update_stream_head_async attempt.stream_id, attempt.stream_revision, attempt.events.length
|
48
57
|
rescue Mongo::OperationFailure, NativeException => e
|
49
58
|
raise(Euston::EventStore::StorageError, e.message, e.backtrace) unless e.message.include? CONCURRENCY_EXCEPTION
|
@@ -122,7 +131,8 @@ module Euston
|
|
122
131
|
|
123
132
|
def mark_commit_as_dispatched(commit)
|
124
133
|
try_mongo do
|
125
|
-
|
134
|
+
# jmongo doesn't currently honour the safe mode on the connection, so we have to specify safe here
|
135
|
+
persisted_commits.update commit.to_id_query, { '$set' => { 'dispatched' => true }}, :safe => true
|
126
136
|
end
|
127
137
|
end
|
128
138
|
|
@@ -152,10 +162,12 @@ module Euston
|
|
152
162
|
|
153
163
|
def update_stream_head_async(stream_id, stream_revision, events_count)
|
154
164
|
Thread.fork do
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
165
|
+
# jmongo doesn't currently honour the safe mode on the connection, so we have to specify safe here
|
166
|
+
id = { '_id' => stream_id }
|
167
|
+
doc = { '$set' => { 'head_revision' => stream_revision },
|
168
|
+
'$inc' => { 'snapshot_revision' => 0, 'unsnapshotted' => events_count } }
|
169
|
+
|
170
|
+
persisted_stream_heads.update id, doc, :upsert => true, :safe => true
|
159
171
|
end
|
160
172
|
end
|
161
173
|
|
@@ -17,12 +17,12 @@ module Euston
|
|
17
17
|
class MongoPersistenceFactory
|
18
18
|
def self.build
|
19
19
|
config = Config.instance
|
20
|
-
|
20
|
+
options = config.options
|
21
|
+
options.merge!(:logger => config.logger) unless config.logger.nil?
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
ZmqPersistenceEngineProxy.new(build.init)
|
23
|
+
@connection ||= Mongo::Connection.from_uri config.uri, options
|
24
|
+
|
25
|
+
MongoPersistenceEngine.new @connection.db(config.database)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -11,13 +11,17 @@ module Euston
|
|
11
11
|
|
12
12
|
id = hash['_id']
|
13
13
|
|
14
|
-
Euston::EventStore::Snapshot.new id['stream_id'],
|
14
|
+
Euston::EventStore::Snapshot.new id['stream_id'],
|
15
|
+
id['stream_revision'],
|
16
|
+
hash['payload'].recursive__symbolize__keys!,
|
17
|
+
hash['headers'].recursive__symbolize__keys!
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
18
21
|
def to_hash
|
19
22
|
{
|
20
23
|
:_id => { :stream_id => stream_id, :stream_revision => stream_revision },
|
24
|
+
:headers => headers,
|
21
25
|
:payload => payload.recursive_stringify_symbol_values!
|
22
26
|
}
|
23
27
|
end
|
@@ -3,7 +3,7 @@ module Euston
|
|
3
3
|
module Persistence
|
4
4
|
# Indicates the most recent information representing the head of a given stream.
|
5
5
|
class StreamHead
|
6
|
-
def initialize
|
6
|
+
def initialize stream_id, head_revision, snapshot_revision
|
7
7
|
@stream_id = stream_id
|
8
8
|
@head_revision = head_revision
|
9
9
|
@snapshot_revision = snapshot_revision
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Euston
|
2
|
+
module Repository
|
3
|
+
class << self
|
4
|
+
def find type, id
|
5
|
+
pair = event_store.get_snapshot_stream_pair id
|
6
|
+
return nil if pair.snapshot.nil? && pair.stream.committed_events.empty?
|
7
|
+
|
8
|
+
type.hydrate pair.stream, pair.snapshot
|
9
|
+
end
|
10
|
+
|
11
|
+
def save aggregate
|
12
|
+
stream = event_store.open_stream :stream_id => aggregate.aggregate_id
|
13
|
+
aggregate.uncommitted_events.each { |e| stream << Euston::EventStore::EventMessage.new(e.to_hash.stringify__keys) }
|
14
|
+
stream.uncommitted_headers[:aggregate_type] = aggregate.class.to_s
|
15
|
+
stream.commit_changes Euston.uuid.generate
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -2,10 +2,11 @@ module Euston
|
|
2
2
|
module EventStore
|
3
3
|
# Represents a materialized view of a stream at specific revision.
|
4
4
|
class Snapshot
|
5
|
-
def initialize
|
5
|
+
def initialize stream_id, stream_revision, payload, headers = nil
|
6
6
|
@stream_id = stream_id
|
7
7
|
@stream_revision = stream_revision
|
8
8
|
@payload = payload
|
9
|
+
@headers = headers || {}
|
9
10
|
end
|
10
11
|
|
11
12
|
# Gets the value which uniquely identifies the stream to which the snapshot applies.
|
@@ -16,6 +17,9 @@ module Euston
|
|
16
17
|
|
17
18
|
# Gets the snapshot or materialized view of the stream at the revision indicated.
|
18
19
|
attr_reader :payload
|
20
|
+
|
21
|
+
# Gets the metadata which provides additional, unstructured information about this snapshot.
|
22
|
+
attr_reader :headers
|
19
23
|
end
|
20
24
|
end
|
21
|
-
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Euston
|
2
|
+
module EventStore
|
3
|
+
# A pair of snapshot & stream to reload an object in a performant way
|
4
|
+
class SnapshotStreamPair
|
5
|
+
def initialize snapshot, stream
|
6
|
+
@snapshot = snapshot
|
7
|
+
@stream = stream
|
8
|
+
end
|
9
|
+
|
10
|
+
# A snapshot providing the state of the object up to the start of the stream
|
11
|
+
attr_reader :snapshot
|
12
|
+
|
13
|
+
# A stream of commits since the snapshot was taken
|
14
|
+
attr_reader :stream
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/euston-eventstore.rb
CHANGED
@@ -1,7 +1,26 @@
|
|
1
1
|
require 'active_support/concern'
|
2
2
|
require 'hash-keys'
|
3
|
-
require 'require_all'
|
4
3
|
|
5
|
-
|
4
|
+
require 'euston-eventstore/commit'
|
5
|
+
require 'euston-eventstore/constants'
|
6
|
+
require 'euston-eventstore/errors'
|
7
|
+
require 'euston-eventstore/event_message'
|
8
|
+
require 'euston-eventstore/optimistic_event_store'
|
9
|
+
require 'euston-eventstore/optimistic_event_stream'
|
10
|
+
require 'euston-eventstore/repository'
|
11
|
+
require 'euston-eventstore/snapshot'
|
12
|
+
require 'euston-eventstore/snapshot_stream_pair'
|
13
|
+
require 'euston-eventstore/dispatcher/asynchronous_dispatcher'
|
14
|
+
require 'euston-eventstore/dispatcher/null_dispatcher'
|
15
|
+
require 'euston-eventstore/dispatcher/synchronous_dispatcher'
|
16
|
+
require 'euston-eventstore/persistence/stream_head'
|
17
|
+
require 'euston-eventstore/persistence/mongodb/mongo_commit'
|
18
|
+
require 'euston-eventstore/persistence/mongodb/mongo_commit_id'
|
19
|
+
require 'euston-eventstore/persistence/mongodb/mongo_config'
|
20
|
+
require 'euston-eventstore/persistence/mongodb/mongo_event_message'
|
21
|
+
require 'euston-eventstore/persistence/mongodb/mongo_persistence_engine'
|
22
|
+
require 'euston-eventstore/persistence/mongodb/mongo_persistence_factory'
|
23
|
+
require 'euston-eventstore/persistence/mongodb/mongo_snapshot'
|
24
|
+
require 'euston-eventstore/persistence/mongodb/mongo_stream_head'
|
6
25
|
|
7
26
|
Json = JSON if defined?(JSON) && !defined?(Json)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
|
2
|
-
|
3
1
|
describe Euston::EventStore do
|
4
2
|
let(:uuid) { Uuid }
|
5
3
|
|
@@ -72,4 +70,4 @@ describe Euston::EventStore do
|
|
72
70
|
Euston::EventStore::Commit.new(defaults.merge options)
|
73
71
|
end
|
74
72
|
end
|
75
|
-
end
|
73
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
|
2
|
-
|
3
1
|
describe Euston::EventStore do
|
4
2
|
describe 'mongodb persistence' do
|
5
3
|
let(:uuid) { Uuid }
|
@@ -181,7 +179,7 @@ describe Euston::EventStore do
|
|
181
179
|
|
182
180
|
context 'when retrieving a snapshot' do
|
183
181
|
let(:too_far_back) { Euston::EventStore::Snapshot.new stream_id, 1, {} }
|
184
|
-
let(:correct) { Euston::EventStore::Snapshot.new stream_id, 3, {
|
182
|
+
let(:correct) { Euston::EventStore::Snapshot.new stream_id, 3, { :key => 'value' } }
|
185
183
|
let(:too_far_forward) { Euston::EventStore::Snapshot.new stream_id, 5, {} }
|
186
184
|
let(:commit1) { new_attempt }
|
187
185
|
let(:commit2) { next_attempt commit1 }
|
@@ -271,6 +269,7 @@ describe Euston::EventStore do
|
|
271
269
|
end
|
272
270
|
|
273
271
|
it('returns all commits on or after the point in time specified') { @committed.should have(4).items }
|
272
|
+
it('returns commits with the same accuracy of timestamp') { @committed[0].commit_timestamp.should == first.commit_timestamp.to_f }
|
274
273
|
end
|
275
274
|
|
276
275
|
def new_attempt(options = {})
|
data/spec/spec_helper.rb
CHANGED
@@ -22,17 +22,19 @@ require 'rspec/core'
|
|
22
22
|
require 'rspec/core/rake_task'
|
23
23
|
require 'rspec/expectations'
|
24
24
|
require 'rspec/mocks'
|
25
|
+
require 'logger'
|
25
26
|
|
26
27
|
require 'support/array_enumeration_counter'
|
27
28
|
|
28
29
|
mongo_config = Euston::EventStore::Persistence::Mongodb::Config.instance
|
29
30
|
mongo_config.database = 'event_store_tests'
|
31
|
+
mongo_config.options = { :safe => true, :fsync => true, :journal => true } #, :logger => Logger.new(STDOUT)
|
30
32
|
|
31
33
|
RSpec.configure do |config|
|
32
34
|
config.fail_fast = true
|
33
35
|
|
34
36
|
config.before :each do
|
35
|
-
connection = Mongo::Connection.
|
37
|
+
connection = Mongo::Connection.from_uri 'mongodb://0.0.0.0:27017/', mongo_config.options
|
36
38
|
db = connection.db(mongo_config.database)
|
37
39
|
db.collections.select { |c| c.name !~ /system/ }.each { |c| db.drop_collection c.name }
|
38
40
|
end
|
metadata
CHANGED
@@ -1,178 +1,190 @@
|
|
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.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.1.0
|
6
6
|
platform: java
|
7
|
-
authors:
|
8
|
-
- Lee Henson
|
9
|
-
- Guy Boertje
|
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
|
-
|
13
|
+
|
14
|
+
date: 2011-10-03 00:00:00 +01:00
|
15
|
+
default_executable:
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: activesupport
|
19
|
+
prerelease: false
|
20
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ~>
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 3.0.9
|
26
|
+
type: :runtime
|
27
|
+
version_requirements: *id001
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: euston
|
30
|
+
prerelease: false
|
31
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ~>
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.1.0
|
37
|
+
type: :runtime
|
38
|
+
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: hash-keys
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.0
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id003
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: json-jruby
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.5.0
|
59
|
+
type: :runtime
|
60
|
+
version_requirements: *id004
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: jmongo
|
63
|
+
prerelease: false
|
64
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.1.0
|
70
|
+
type: :runtime
|
71
|
+
version_requirements: *id005
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: awesome_print
|
74
|
+
prerelease: false
|
75
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ~>
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.4.0
|
81
|
+
type: :development
|
82
|
+
version_requirements: *id006
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fuubar
|
85
|
+
prerelease: false
|
86
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ~>
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 0.0.0
|
92
|
+
type: :development
|
93
|
+
version_requirements: *id007
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rake
|
96
|
+
prerelease: false
|
97
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.9.2
|
103
|
+
type: :development
|
104
|
+
version_requirements: *id008
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rspec
|
107
|
+
prerelease: false
|
108
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ~>
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: 2.6.0
|
114
|
+
type: :development
|
115
|
+
version_requirements: *id009
|
114
116
|
description: Ruby port for Jonathan Oliver's EventStore. See https://github.com/joliver/EventStore for details.
|
115
|
-
email:
|
116
|
-
- lee.m.henson@gmail.com
|
117
|
-
- guyboertje@gmail.com
|
117
|
+
email:
|
118
|
+
- lee.m.henson@gmail.com
|
119
|
+
- guyboertje@gmail.com
|
118
120
|
executables: []
|
121
|
+
|
119
122
|
extensions: []
|
123
|
+
|
120
124
|
extra_rdoc_files: []
|
121
|
-
|
122
|
-
|
123
|
-
-
|
124
|
-
-
|
125
|
-
-
|
126
|
-
- lib/euston-eventstore
|
127
|
-
- lib/euston-eventstore/
|
128
|
-
- lib/euston-eventstore/
|
129
|
-
- lib/euston-eventstore/dispatcher/
|
130
|
-
- lib/euston-eventstore/
|
131
|
-
- lib/euston-eventstore/
|
132
|
-
- lib/euston-eventstore/
|
133
|
-
- lib/euston-eventstore/
|
134
|
-
- lib/euston-eventstore/
|
135
|
-
- lib/euston-eventstore/
|
136
|
-
- lib/euston-eventstore/persistence/mongodb/
|
137
|
-
- lib/euston-eventstore/persistence/mongodb/
|
138
|
-
- lib/euston-eventstore/persistence/mongodb/
|
139
|
-
- lib/euston-eventstore/persistence/mongodb/
|
140
|
-
- lib/euston-eventstore/persistence/mongodb/
|
141
|
-
- lib/euston-eventstore/persistence/mongodb/
|
142
|
-
- lib/euston-eventstore/persistence/
|
143
|
-
- lib/euston-eventstore/
|
144
|
-
- lib/euston-eventstore/
|
145
|
-
-
|
146
|
-
-
|
147
|
-
-
|
148
|
-
-
|
149
|
-
- spec/event_store/
|
150
|
-
- spec/event_store/
|
151
|
-
- spec/
|
152
|
-
- spec/
|
125
|
+
|
126
|
+
files:
|
127
|
+
- Gemfile
|
128
|
+
- Rakefile
|
129
|
+
- euston-eventstore.gemspec
|
130
|
+
- lib/euston-eventstore.rb
|
131
|
+
- lib/euston-eventstore/commit.rb
|
132
|
+
- lib/euston-eventstore/constants.rb
|
133
|
+
- lib/euston-eventstore/dispatcher/asynchronous_dispatcher.rb
|
134
|
+
- lib/euston-eventstore/dispatcher/null_dispatcher.rb
|
135
|
+
- lib/euston-eventstore/dispatcher/synchronous_dispatcher.rb
|
136
|
+
- lib/euston-eventstore/errors.rb
|
137
|
+
- lib/euston-eventstore/event_message.rb
|
138
|
+
- lib/euston-eventstore/optimistic_event_store.rb
|
139
|
+
- lib/euston-eventstore/optimistic_event_stream.rb
|
140
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_commit.rb
|
141
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_commit_id.rb
|
142
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_config.rb
|
143
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_event_message.rb
|
144
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_persistence_engine.rb
|
145
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_persistence_factory.rb
|
146
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_snapshot.rb
|
147
|
+
- lib/euston-eventstore/persistence/mongodb/mongo_stream_head.rb
|
148
|
+
- lib/euston-eventstore/persistence/stream_head.rb
|
149
|
+
- lib/euston-eventstore/repository.rb
|
150
|
+
- lib/euston-eventstore/snapshot.rb
|
151
|
+
- lib/euston-eventstore/snapshot_stream_pair.rb
|
152
|
+
- lib/euston-eventstore/version.rb
|
153
|
+
- spec/event_store/dispatcher/asynchronous_dispatcher_spec.rb
|
154
|
+
- spec/event_store/dispatcher/synchronous_dispatcher_spec.rb
|
155
|
+
- spec/event_store/optimistic_event_store_spec.rb
|
156
|
+
- spec/event_store/optimistic_event_stream_spec.rb
|
157
|
+
- spec/event_store/persistence/mongodb_spec.rb
|
158
|
+
- spec/event_store/serialization/simple_message.rb
|
159
|
+
- spec/spec_helper.rb
|
160
|
+
- spec/support/array_enumeration_counter.rb
|
161
|
+
has_rdoc: true
|
153
162
|
homepage: http://github.com/leemhenson/euston-eventstore
|
154
163
|
licenses: []
|
155
|
-
|
164
|
+
|
165
|
+
post_install_message:
|
156
166
|
rdoc_options: []
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
- - ! '>='
|
162
|
-
- !ruby/object:Gem::Version
|
163
|
-
version: '0'
|
167
|
+
|
168
|
+
require_paths:
|
169
|
+
- lib
|
170
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
164
171
|
none: false
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: "0"
|
176
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
177
|
none: false
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: "0"
|
171
182
|
requirements: []
|
172
|
-
|
173
|
-
|
174
|
-
|
183
|
+
|
184
|
+
rubyforge_project:
|
185
|
+
rubygems_version: 1.5.1
|
186
|
+
signing_key:
|
175
187
|
specification_version: 3
|
176
188
|
summary: Event store for use with Euston.
|
177
189
|
test_files: []
|
178
|
-
|
190
|
+
|