ruby_event_store-rom 1.3.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/ruby_event_store/rom/changesets/create_events.rb +10 -18
- data/lib/ruby_event_store/rom/changesets/create_stream_entries.rb +3 -12
- data/lib/ruby_event_store/rom/changesets/update_events.rb +33 -19
- data/lib/ruby_event_store/rom/event_repository.rb +65 -61
- data/lib/ruby_event_store/rom/index_violation_detector.rb +25 -0
- data/lib/ruby_event_store/rom/mappers/event_to_serialized_record.rb +10 -6
- data/lib/ruby_event_store/rom/mappers/stream_entry_to_serialized_record.rb +11 -6
- data/lib/ruby_event_store/rom/rake_task.rb +5 -0
- data/lib/ruby_event_store/rom/relations/events.rb +78 -0
- data/lib/ruby_event_store/rom/relations/stream_entries.rb +83 -0
- data/lib/ruby_event_store/rom/repositories/events.rb +55 -30
- data/lib/ruby_event_store/rom/repositories/stream_entries.rb +15 -16
- data/lib/ruby_event_store/rom/tasks/migration_tasks.rake +36 -0
- data/lib/ruby_event_store/rom/types.rb +16 -14
- data/lib/ruby_event_store/rom/unit_of_work.rb +28 -13
- data/lib/ruby_event_store/rom/version.rb +1 -1
- data/lib/ruby_event_store/rom.rb +28 -103
- data/lib/ruby_event_store-rom.rb +1 -1
- metadata +31 -49
- data/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +0 -84
- data/CHANGELOG.md +0 -9
- data/Gemfile +0 -12
- data/Makefile +0 -57
- data/Rakefile +0 -20
- data/db/migrate/20180327044629_create_ruby_event_store_tables.rb +0 -54
- data/db/migrate/20181026152045_index_by_event_type.rb +0 -9
- data/lib/ruby_event_store/rom/adapters/memory/changesets/create_events.rb +0 -19
- data/lib/ruby_event_store/rom/adapters/memory/changesets/create_stream_entries.rb +0 -19
- data/lib/ruby_event_store/rom/adapters/memory/changesets/update_events.rb +0 -18
- data/lib/ruby_event_store/rom/adapters/memory/relations/events.rb +0 -56
- data/lib/ruby_event_store/rom/adapters/memory/relations/stream_entries.rb +0 -114
- data/lib/ruby_event_store/rom/adapters/memory/unit_of_work.rb +0 -36
- data/lib/ruby_event_store/rom/adapters/sql/changesets/create_events.rb +0 -15
- data/lib/ruby_event_store/rom/adapters/sql/changesets/update_events.rb +0 -41
- data/lib/ruby_event_store/rom/adapters/sql/index_violation_detector.rb +0 -31
- data/lib/ruby_event_store/rom/adapters/sql/rake_task.rb +0 -5
- data/lib/ruby_event_store/rom/adapters/sql/relations/events.rb +0 -27
- data/lib/ruby_event_store/rom/adapters/sql/relations/stream_entries.rb +0 -72
- data/lib/ruby_event_store/rom/adapters/sql/tasks/migration_tasks.rake +0 -36
- data/lib/ruby_event_store/rom/memory.rb +0 -82
- data/lib/ruby_event_store/rom/sql.rb +0 -169
- data/lib/ruby_event_store/rom/tuple_uniqueness_error.rb +0 -21
- data/lib/ruby_event_store/spec/rom/event_repository_lint.rb +0 -176
- data/lib/ruby_event_store/spec/rom/relations/events_lint.rb +0 -75
- data/lib/ruby_event_store/spec/rom/relations/stream_entries_lint.rb +0 -198
- data/lib/ruby_event_store/spec/rom/spec_helper_lint.rb +0 -15
- data/lib/ruby_event_store/spec/rom/unit_of_work_lint.rb +0 -37
- data/ruby_event_store-rom.gemspec +0 -37
@@ -1,52 +1,46 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../mappers/event_to_serialized_record'
|
4
|
-
require_relative '../changesets/create_events'
|
5
|
-
require_relative '../changesets/update_events'
|
6
|
-
|
7
3
|
module RubyEventStore
|
8
4
|
module ROM
|
9
5
|
module Repositories
|
10
6
|
class Events < ::ROM::Repository[:events]
|
11
|
-
def create_changeset(
|
12
|
-
events.create_changeset(
|
7
|
+
def create_changeset(records)
|
8
|
+
events.create_changeset(records)
|
13
9
|
end
|
14
10
|
|
15
|
-
def update_changeset(
|
16
|
-
events.update_changeset(
|
11
|
+
def update_changeset(records)
|
12
|
+
events.update_changeset(records)
|
17
13
|
end
|
18
14
|
|
19
15
|
def find_nonexistent_pks(event_ids)
|
20
16
|
return event_ids unless event_ids.any?
|
21
17
|
|
22
|
-
event_ids - events.
|
18
|
+
event_ids - events.by_event_id(event_ids).pluck(:event_id)
|
23
19
|
end
|
24
20
|
|
25
21
|
def exist?(event_id)
|
26
|
-
events.
|
27
|
-
end
|
28
|
-
|
29
|
-
def by_id(event_id)
|
30
|
-
events.map_with(:event_to_serialized_record).by_pk(event_id).one!
|
22
|
+
events.by_event_id(event_id).exist?
|
31
23
|
end
|
32
24
|
|
33
|
-
def last_stream_event(stream)
|
25
|
+
def last_stream_event(stream, serializer)
|
34
26
|
query = stream_entries.ordered(:backward, stream)
|
35
|
-
query =
|
27
|
+
query = query.combine(:event)
|
28
|
+
query = query.map_with(:stream_entry_to_serialized_record, auto_struct: false)
|
29
|
+
query = query_builder(serializer, query, limit: 1)
|
36
30
|
query.first
|
37
31
|
end
|
38
32
|
|
39
|
-
def read(specification)
|
33
|
+
def read(specification, serializer)
|
40
34
|
query = read_scope(specification)
|
41
35
|
|
42
36
|
if specification.batched?
|
43
37
|
BatchEnumerator.new(
|
44
38
|
specification.batch_size,
|
45
39
|
specification.limit,
|
46
|
-
->(offset, limit) { query_builder(query, offset: offset, limit: limit).to_ary }
|
40
|
+
->(offset, limit) { query_builder(serializer, query, offset: offset, limit: limit).to_ary }
|
47
41
|
).each
|
48
42
|
else
|
49
|
-
query = query_builder(query, limit: (specification.limit if specification.limit?))
|
43
|
+
query = query_builder(serializer, query, limit: (specification.limit if specification.limit?))
|
50
44
|
if !specification.start && !specification.stop
|
51
45
|
specification.first? || specification.last? ? query.first : query.each
|
52
46
|
elsif specification.last?
|
@@ -59,35 +53,66 @@ module RubyEventStore
|
|
59
53
|
|
60
54
|
def count(specification)
|
61
55
|
query = read_scope(specification)
|
62
|
-
query = query.
|
56
|
+
query = query.limit(specification.limit) if specification.limit?
|
63
57
|
query.count
|
64
58
|
end
|
65
59
|
|
60
|
+
def global_position(event_id)
|
61
|
+
record = events.by_event_id(event_id).one
|
62
|
+
raise EventNotFound.new(event_id) if record.nil?
|
63
|
+
record.id - 1
|
64
|
+
end
|
65
|
+
|
66
66
|
protected
|
67
67
|
|
68
68
|
def read_scope(specification)
|
69
|
-
offset_entry_id = stream_entries.by_stream_and_event_id(specification.stream, specification.start).fetch(:id) if specification.start
|
70
|
-
stop_entry_id = stream_entries.by_stream_and_event_id(specification.stream, specification.stop).fetch(:id) if specification.stop
|
71
|
-
|
72
69
|
direction = specification.forward? ? :forward : :backward
|
73
70
|
|
74
71
|
if specification.last? && !specification.start && !specification.stop
|
75
72
|
direction = specification.forward? ? :backward : :forward
|
76
73
|
end
|
77
74
|
|
78
|
-
|
75
|
+
if specification.stream.global?
|
76
|
+
offset_entry_id = events.by_event_id(specification.start).one!.fetch(:id) if specification.start
|
77
|
+
stop_entry_id = events.by_event_id(specification.stop).one!.fetch(:id) if specification.stop
|
78
|
+
|
79
|
+
query = events.ordered(direction, offset_entry_id, stop_entry_id, specification.time_sort_by)
|
80
|
+
query = query.map_with(:event_to_serialized_record, auto_struct: false)
|
81
|
+
else
|
82
|
+
offset_entry_id =
|
83
|
+
stream_entries
|
84
|
+
.by_stream_and_event_id(specification.stream, specification.start)
|
85
|
+
.fetch(:id) if specification.start
|
86
|
+
stop_entry_id =
|
87
|
+
stream_entries
|
88
|
+
.by_stream_and_event_id(specification.stream, specification.stop)
|
89
|
+
.fetch(:id) if specification.stop
|
90
|
+
|
91
|
+
query =
|
92
|
+
stream_entries.ordered(
|
93
|
+
direction,
|
94
|
+
specification.stream,
|
95
|
+
offset_entry_id,
|
96
|
+
stop_entry_id,
|
97
|
+
specification.time_sort_by
|
98
|
+
)
|
99
|
+
query = query.combine(:event)
|
100
|
+
query = query.map_with(:stream_entry_to_serialized_record, auto_struct: false)
|
101
|
+
end
|
102
|
+
|
79
103
|
query = query.by_event_id(specification.with_ids) if specification.with_ids
|
80
104
|
query = query.by_event_type(specification.with_types) if specification.with_types?
|
105
|
+
query = query.older_than(specification.older_than) if specification.older_than
|
106
|
+
query = query.older_than_or_equal(specification.older_than_or_equal) if specification.older_than_or_equal
|
107
|
+
query = query.newer_than(specification.newer_than) if specification.newer_than
|
108
|
+
query = query.newer_than_or_equal(specification.newer_than_or_equal) if specification.newer_than_or_equal
|
81
109
|
query
|
82
110
|
end
|
83
111
|
|
84
|
-
def query_builder(query, offset: nil, limit: nil)
|
112
|
+
def query_builder(serializer, query, offset: nil, limit: nil)
|
85
113
|
query = query.offset(offset) if offset
|
86
|
-
query = query.
|
87
|
-
|
88
|
-
query
|
89
|
-
.combine(:event)
|
90
|
-
.map_with(:stream_entry_to_serialized_record, auto_struct: false)
|
114
|
+
query = query.limit(limit) if limit
|
115
|
+
query.to_a.map { |serialized_record| serialized_record.deserialize(serializer) }
|
91
116
|
end
|
92
117
|
end
|
93
118
|
end
|
@@ -1,15 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../mappers/stream_entry_to_serialized_record'
|
4
|
-
require_relative '../changesets/create_stream_entries'
|
5
|
-
|
6
3
|
module RubyEventStore
|
7
4
|
module ROM
|
8
5
|
module Repositories
|
9
6
|
class StreamEntries < ::ROM::Repository[:stream_entries]
|
10
7
|
POSITION_SHIFT = 1
|
11
8
|
|
12
|
-
def create_changeset(event_ids, stream, resolved_version
|
9
|
+
def create_changeset(event_ids, stream, resolved_version)
|
13
10
|
tuples = []
|
14
11
|
|
15
12
|
event_ids.each_with_index do |event_id, index|
|
@@ -20,14 +17,6 @@ module RubyEventStore
|
|
20
17
|
event_id: event_id
|
21
18
|
}
|
22
19
|
end
|
23
|
-
|
24
|
-
next unless global_stream
|
25
|
-
|
26
|
-
tuples << {
|
27
|
-
stream: stream_entries.class::SERIALIZED_GLOBAL_STREAM_NAME,
|
28
|
-
position: nil,
|
29
|
-
event_id: event_id
|
30
|
-
}
|
31
20
|
end
|
32
21
|
|
33
22
|
stream_entries.create_changeset(tuples)
|
@@ -38,14 +27,24 @@ module RubyEventStore
|
|
38
27
|
end
|
39
28
|
|
40
29
|
def resolve_version(stream, expected_version)
|
41
|
-
expected_version.resolve_for(
|
42
|
-
|
43
|
-
|
30
|
+
expected_version.resolve_for(
|
31
|
+
stream,
|
32
|
+
lambda { |_stream| (stream_entries.max_position(stream) || {})[:position] }
|
33
|
+
)
|
44
34
|
end
|
45
35
|
|
46
36
|
def streams_of(event_id)
|
47
37
|
stream_entries.by_event_id(event_id).map { |e| e[:stream] }
|
48
|
-
|
38
|
+
end
|
39
|
+
|
40
|
+
def position_in_stream(event_id, stream)
|
41
|
+
record = stream_entries.by_stream(stream).by_event_id(event_id).one
|
42
|
+
raise EventNotFoundInStream if record.nil?
|
43
|
+
record.position
|
44
|
+
end
|
45
|
+
|
46
|
+
def event_in_stream?(event_id, stream)
|
47
|
+
stream_entries.by_stream(stream).by_event_id(event_id).exist?
|
49
48
|
end
|
50
49
|
end
|
51
50
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ruby_event_store/rom"
|
4
|
+
|
5
|
+
MIGRATIONS_PATH = "db/migrate".freeze
|
6
|
+
|
7
|
+
desc "Setup ROM EventRespository environment"
|
8
|
+
task "db:setup" do
|
9
|
+
Dir.chdir(Dir.pwd)
|
10
|
+
ROM::SQL::RakeSupport.env = ::RubyEventStore::ROM.rom_container(:sql, ENV["DATABASE_URL"])
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Copy RubyEventStore SQL migrations to db/migrate"
|
14
|
+
task "db:migrations:copy" => "db:setup" do
|
15
|
+
# Optional data type for `data` and `metadata`
|
16
|
+
data_type = ENV["DATA_TYPE"]
|
17
|
+
|
18
|
+
Dir[File.join(File.dirname(__FILE__), "../../../../", MIGRATIONS_PATH, "/*.rb")].each do |input|
|
19
|
+
contents = File.read(input)
|
20
|
+
name = File.basename(input, ".*").sub(/\d+_/, "")
|
21
|
+
|
22
|
+
re_data_type = /(ENV.+?DATA_TYPE.+?\|\|=\s*)['"](jsonb?|text)['"]/
|
23
|
+
|
24
|
+
if data_type && contents =~ re_data_type
|
25
|
+
# Search/replace this string: ENV['DATA_TYPE'] ||= 'text'
|
26
|
+
contents = contents.sub(re_data_type, format('\1"%<data_type>s"', data_type: data_type))
|
27
|
+
name += "_with_#{data_type}"
|
28
|
+
end
|
29
|
+
|
30
|
+
output = ROM::SQL::RakeSupport.create_migration(name)
|
31
|
+
|
32
|
+
File.write output, contents
|
33
|
+
|
34
|
+
puts "<= migration file created #{output}"
|
35
|
+
end
|
36
|
+
end
|
@@ -3,22 +3,24 @@
|
|
3
3
|
module RubyEventStore
|
4
4
|
module ROM
|
5
5
|
module Types
|
6
|
-
DateTime =
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
6
|
+
DateTime =
|
7
|
+
::ROM::Types::DateTime
|
8
|
+
.constructor do |value|
|
9
|
+
case value
|
10
|
+
when nil
|
11
|
+
Dry::Core::Constants::Undefined
|
12
|
+
when ::String
|
13
|
+
::DateTime.iso8601(value)
|
14
|
+
else
|
15
|
+
value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
.default { ::DateTime.now.new_offset(0) }
|
18
19
|
|
19
|
-
SerializedRecordSerializer = ::ROM::Types::String
|
20
20
|
# detects if the value is a Sequel::Postgres::JSONHash or Sequel::Postgres::JSONBHash
|
21
|
-
|
21
|
+
RecordDeserializer =
|
22
|
+
::ROM::Types::String.constructor { |v| v.class.name.upcase.include?("JSON") ? JSON.dump(v) : v }
|
23
|
+
RecordSerializer = ::ROM::Types::String
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
@@ -3,22 +3,37 @@
|
|
3
3
|
module RubyEventStore
|
4
4
|
module ROM
|
5
5
|
class UnitOfWork
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(rom: ROM.env)
|
9
|
-
@env = rom
|
6
|
+
def initialize(gateway)
|
7
|
+
@gateway = gateway
|
10
8
|
end
|
11
9
|
|
12
|
-
def call
|
13
|
-
gateway = @env.rom_container.gateways.fetch(options.delete(:gateway) { :default })
|
14
|
-
|
10
|
+
def call
|
15
11
|
yield(changesets = [])
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
@gateway.transaction(
|
13
|
+
savepoint: true,
|
14
|
+
# See: https://github.com/jeremyevans/sequel/blob/master/doc/transactions.rdoc
|
15
|
+
#
|
16
|
+
# Committing changesets concurrently causes MySQL deadlocks
|
17
|
+
# which are not caught and retried by Sequel's built-in
|
18
|
+
# :retry_on option. This appears to be a result of how ROM
|
19
|
+
# handles exceptions which don't bubble up so that Sequel
|
20
|
+
# can retry transactions with the :retry_on option when there's
|
21
|
+
# a deadlock.
|
22
|
+
#
|
23
|
+
# This is exacerbated by the fact that changesets insert multiple
|
24
|
+
# tuples with individual INSERT statements because ROM specifies
|
25
|
+
# to Sequel to return a list of primary keys created. The likelihood
|
26
|
+
# of a deadlock is reduced with batched INSERT statements.
|
27
|
+
#
|
28
|
+
# For this reason we need to manually insert changeset records to avoid
|
29
|
+
# MySQL deadlocks or to allow Sequel to retry transactions
|
30
|
+
# when the :retry_on option is specified.
|
31
|
+
retry_on: Sequel::SerializationFailure,
|
32
|
+
before_retry:
|
33
|
+
lambda do |_num, ex|
|
34
|
+
env.logger.warn("RETRY TRANSACTION [#{self.class.name} => #{ex.class.name}] #{ex.message}")
|
35
|
+
end
|
36
|
+
) { changesets.each(&:commit) }
|
22
37
|
end
|
23
38
|
end
|
24
39
|
end
|
data/lib/ruby_event_store/rom.rb
CHANGED
@@ -1,116 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
3
|
+
require "ruby_event_store"
|
4
|
+
require "rom"
|
5
|
+
require "rom/sql"
|
6
|
+
require "rom/transformer"
|
7
|
+
|
8
|
+
require_relative "rom/changesets/create_events"
|
9
|
+
require_relative "rom/changesets/create_stream_entries"
|
10
|
+
require_relative "rom/changesets/update_events"
|
11
|
+
require_relative "rom/event_repository"
|
12
|
+
require_relative "rom/index_violation_detector"
|
13
|
+
require_relative "rom/mappers/event_to_serialized_record"
|
14
|
+
require_relative "rom/mappers/stream_entry_to_serialized_record"
|
15
|
+
require_relative "rom/relations/events"
|
16
|
+
require_relative "rom/relations/stream_entries"
|
17
|
+
require_relative "rom/repositories/events"
|
18
|
+
require_relative "rom/repositories/stream_entries"
|
19
|
+
require_relative "rom/types"
|
20
|
+
require_relative "rom/unit_of_work"
|
14
21
|
|
15
22
|
module RubyEventStore
|
16
23
|
module ROM
|
17
|
-
class
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
register(:unique_violation_error_handlers, Set.new)
|
26
|
-
register(:not_found_error_handlers, Set.new)
|
27
|
-
register(:logger, Logger.new(STDOUT).tap { |logger| logger.level = Logger::WARN })
|
28
|
-
end
|
29
|
-
|
30
|
-
def logger
|
31
|
-
resolve(:logger)
|
32
|
-
end
|
33
|
-
|
34
|
-
def unit_of_work(&block)
|
35
|
-
options = resolve(:unit_of_work_options).dup
|
36
|
-
options.delete(:class) { UnitOfWork }.new(rom: self).call(**options, &block)
|
37
|
-
end
|
38
|
-
|
39
|
-
def register_unit_of_work_options(options)
|
40
|
-
register(:unit_of_work_options, options)
|
41
|
-
end
|
42
|
-
|
43
|
-
def register_error_handler(type, handler)
|
44
|
-
resolve(:"#{type}_error_handlers") << handler
|
45
|
-
end
|
46
|
-
|
47
|
-
def handle_error(type, *args, swallow: [])
|
48
|
-
yield
|
49
|
-
rescue StandardError => e
|
50
|
-
begin
|
51
|
-
resolve(:"#{type}_error_handlers").each { |h| h.call(e, *args) }
|
52
|
-
raise e
|
53
|
-
rescue *swallow
|
54
|
-
# swallow
|
24
|
+
class << self
|
25
|
+
def setup(adapter_name, database_uri = ENV["DATABASE_URL"])
|
26
|
+
rom_container(adapter_name, database_uri) do |rom|
|
27
|
+
rom.register_mapper Mappers::StreamEntryToSerializedRecord
|
28
|
+
rom.register_mapper Mappers::EventToSerializedRecord
|
29
|
+
rom.register_relation Relations::Events
|
30
|
+
rom.register_relation Relations::StreamEntries
|
55
31
|
end
|
56
32
|
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class << self
|
60
|
-
# Set to a default instance
|
61
|
-
attr_accessor :env
|
62
33
|
|
63
|
-
def
|
34
|
+
def rom_container(adapter_name, database_uri, &block)
|
64
35
|
if adapter_name.is_a?(::ROM::Configuration)
|
65
|
-
|
66
|
-
Env.new ::ROM.container(adapter_name.tap(&block), &block)
|
36
|
+
::ROM.container(adapter_name.tap(&block), &block)
|
67
37
|
else
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def setup(*args, &block)
|
73
|
-
configure(*args) do |config|
|
74
|
-
setup_defaults(config)
|
75
|
-
yield(config) if block
|
76
|
-
end.tap(&method(:configure_defaults))
|
77
|
-
end
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
def setup_defaults(config)
|
82
|
-
require_relative 'rom/repositories/stream_entries'
|
83
|
-
require_relative 'rom/repositories/events'
|
84
|
-
|
85
|
-
config.register_mapper(ROM::Mappers::EventToSerializedRecord)
|
86
|
-
config.register_mapper(ROM::Mappers::StreamEntryToSerializedRecord)
|
87
|
-
|
88
|
-
find_adapters(config.environment.gateways).each do |adapter|
|
89
|
-
adapter.setup(config)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def configure_defaults(env)
|
94
|
-
env.register_error_handler :not_found, lambda { |ex, event_id|
|
95
|
-
case ex
|
96
|
-
when ::ROM::TupleCountMismatchError
|
97
|
-
raise EventNotFound, event_id
|
98
|
-
end
|
99
|
-
}
|
100
|
-
|
101
|
-
find_adapters(env.rom_container.gateways).each do |adapter|
|
102
|
-
adapter.configure(env)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def find_adapters(gateways)
|
107
|
-
# Setup for each kind of gateway class
|
108
|
-
gateways.values.map(&:class).uniq.map do |klass|
|
109
|
-
constant = klass.name.split('::')[1].to_sym
|
110
|
-
|
111
|
-
next unless RubyEventStore::ROM.constants.include?(constant)
|
112
|
-
|
113
|
-
RubyEventStore::ROM.const_get(constant)
|
38
|
+
::ROM.container(adapter_name, database_uri, &block)
|
114
39
|
end
|
115
40
|
end
|
116
41
|
end
|
data/lib/ruby_event_store-rom.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_event_store-rom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Van Horn
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-container
|
@@ -95,92 +95,74 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: sequel
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 5.11.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 5.11.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: ruby_event_store
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 2.0.0
|
118
|
+
- - "<"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 3.0.0
|
118
121
|
type: :runtime
|
119
122
|
prerelease: false
|
120
123
|
version_requirements: !ruby/object:Gem::Requirement
|
121
124
|
requirements:
|
122
125
|
- - ">="
|
123
126
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
125
|
-
|
126
|
-
|
127
|
-
|
127
|
+
version: 2.0.0
|
128
|
+
- - "<"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 3.0.0
|
131
|
+
description: Implementation of events repository based on ROM for Ruby Event Store
|
132
|
+
email: joel@joelvanhorn.com
|
128
133
|
executables: []
|
129
134
|
extensions: []
|
130
|
-
extra_rdoc_files:
|
135
|
+
extra_rdoc_files:
|
136
|
+
- README.md
|
131
137
|
files:
|
132
|
-
- ".rubocop.yml"
|
133
|
-
- ".rubocop_todo.yml"
|
134
|
-
- CHANGELOG.md
|
135
|
-
- Gemfile
|
136
|
-
- Makefile
|
137
138
|
- README.md
|
138
|
-
- Rakefile
|
139
|
-
- db/migrate/20180327044629_create_ruby_event_store_tables.rb
|
140
|
-
- db/migrate/20181026152045_index_by_event_type.rb
|
141
139
|
- lib/ruby_event_store-rom.rb
|
142
140
|
- lib/ruby_event_store/rom.rb
|
143
|
-
- lib/ruby_event_store/rom/adapters/memory/changesets/create_events.rb
|
144
|
-
- lib/ruby_event_store/rom/adapters/memory/changesets/create_stream_entries.rb
|
145
|
-
- lib/ruby_event_store/rom/adapters/memory/changesets/update_events.rb
|
146
|
-
- lib/ruby_event_store/rom/adapters/memory/relations/events.rb
|
147
|
-
- lib/ruby_event_store/rom/adapters/memory/relations/stream_entries.rb
|
148
|
-
- lib/ruby_event_store/rom/adapters/memory/unit_of_work.rb
|
149
|
-
- lib/ruby_event_store/rom/adapters/sql/changesets/create_events.rb
|
150
|
-
- lib/ruby_event_store/rom/adapters/sql/changesets/update_events.rb
|
151
|
-
- lib/ruby_event_store/rom/adapters/sql/index_violation_detector.rb
|
152
|
-
- lib/ruby_event_store/rom/adapters/sql/rake_task.rb
|
153
|
-
- lib/ruby_event_store/rom/adapters/sql/relations/events.rb
|
154
|
-
- lib/ruby_event_store/rom/adapters/sql/relations/stream_entries.rb
|
155
|
-
- lib/ruby_event_store/rom/adapters/sql/tasks/migration_tasks.rake
|
156
141
|
- lib/ruby_event_store/rom/changesets/create_events.rb
|
157
142
|
- lib/ruby_event_store/rom/changesets/create_stream_entries.rb
|
158
143
|
- lib/ruby_event_store/rom/changesets/update_events.rb
|
159
144
|
- lib/ruby_event_store/rom/event_repository.rb
|
145
|
+
- lib/ruby_event_store/rom/index_violation_detector.rb
|
160
146
|
- lib/ruby_event_store/rom/mappers/event_to_serialized_record.rb
|
161
147
|
- lib/ruby_event_store/rom/mappers/stream_entry_to_serialized_record.rb
|
162
|
-
- lib/ruby_event_store/rom/
|
148
|
+
- lib/ruby_event_store/rom/rake_task.rb
|
149
|
+
- lib/ruby_event_store/rom/relations/events.rb
|
150
|
+
- lib/ruby_event_store/rom/relations/stream_entries.rb
|
163
151
|
- lib/ruby_event_store/rom/repositories/events.rb
|
164
152
|
- lib/ruby_event_store/rom/repositories/stream_entries.rb
|
165
|
-
- lib/ruby_event_store/rom/
|
166
|
-
- lib/ruby_event_store/rom/tuple_uniqueness_error.rb
|
153
|
+
- lib/ruby_event_store/rom/tasks/migration_tasks.rake
|
167
154
|
- lib/ruby_event_store/rom/types.rb
|
168
155
|
- lib/ruby_event_store/rom/unit_of_work.rb
|
169
156
|
- lib/ruby_event_store/rom/version.rb
|
170
|
-
- lib/ruby_event_store/spec/rom/event_repository_lint.rb
|
171
|
-
- lib/ruby_event_store/spec/rom/relations/events_lint.rb
|
172
|
-
- lib/ruby_event_store/spec/rom/relations/stream_entries_lint.rb
|
173
|
-
- lib/ruby_event_store/spec/rom/spec_helper_lint.rb
|
174
|
-
- lib/ruby_event_store/spec/rom/unit_of_work_lint.rb
|
175
|
-
- ruby_event_store-rom.gemspec
|
176
157
|
homepage: https://railseventstore.org
|
177
158
|
licenses:
|
178
159
|
- MIT
|
179
160
|
metadata:
|
180
|
-
homepage_uri: https://railseventstore.org
|
181
|
-
changelog_uri: https://github.com/RailsEventStore/rails_event_store/
|
161
|
+
homepage_uri: https://railseventstore.org
|
162
|
+
changelog_uri: https://github.com/RailsEventStore/rails_event_store/blob/master/contrib/ruby_event_store-rom/CHANGELOG.md
|
182
163
|
source_code_uri: https://github.com/RailsEventStore/rails_event_store
|
183
164
|
bug_tracker_uri: https://github.com/RailsEventStore/rails_event_store/issues
|
165
|
+
rubygems_mfa_required: 'true'
|
184
166
|
post_install_message:
|
185
167
|
rdoc_options: []
|
186
168
|
require_paths:
|
@@ -189,14 +171,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
189
171
|
requirements:
|
190
172
|
- - ">="
|
191
173
|
- !ruby/object:Gem::Version
|
192
|
-
version: '2.
|
174
|
+
version: '2.5'
|
193
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
176
|
requirements:
|
195
177
|
- - ">="
|
196
178
|
- !ruby/object:Gem::Version
|
197
179
|
version: '0'
|
198
180
|
requirements: []
|
199
|
-
rubygems_version: 3.
|
181
|
+
rubygems_version: 3.4.6
|
200
182
|
signing_key:
|
201
183
|
specification_version: 4
|
202
184
|
summary: ROM events repository for Ruby Event Store
|
data/.rubocop.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|