sandthorn_driver_sequel 3.2.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -4
  3. data/lib/sandthorn_driver_sequel/access/aggregate_access.rb +0 -4
  4. data/lib/sandthorn_driver_sequel/access/event_access.rb +11 -15
  5. data/lib/sandthorn_driver_sequel/errors.rb +0 -14
  6. data/lib/sandthorn_driver_sequel/event_query.rb +3 -2
  7. data/lib/sandthorn_driver_sequel/event_store.rb +10 -98
  8. data/lib/sandthorn_driver_sequel/event_store_context.rb +3 -3
  9. data/lib/sandthorn_driver_sequel/migration.rb +20 -3
  10. data/lib/sandthorn_driver_sequel/storage.rb +0 -9
  11. data/lib/sandthorn_driver_sequel/version.rb +1 -1
  12. data/lib/sandthorn_driver_sequel/wrappers/event_wrapper.rb +1 -1
  13. data/lib/sandthorn_driver_sequel/wrappers.rb +0 -1
  14. data/lib/sandthorn_driver_sequel.rb +0 -26
  15. data/sandthorn_driver_sequel.gemspec +2 -3
  16. data/spec/aggregate_access_spec.rb +0 -10
  17. data/spec/benchmark_spec.rb +6 -35
  18. data/spec/configuration_spec.rb +0 -29
  19. data/spec/driver_interface_spec.rb +0 -7
  20. data/spec/event_access_spec.rb +4 -22
  21. data/spec/event_store_spec.rb +43 -73
  22. data/spec/event_store_with_context_spec.rb +5 -5
  23. data/spec/get_events_spec.rb +12 -47
  24. data/spec/migration_specifying_domain_spec.rb +6 -6
  25. data/spec/saving_events_spec.rb +22 -28
  26. data/spec/storage_spec.rb +1 -0
  27. metadata +8 -31
  28. data/lib/sandthorn_driver_sequel/access/snapshot_access.rb +0 -105
  29. data/lib/sandthorn_driver_sequel/wrappers/snapshot_wrapper.rb +0 -19
  30. data/spec/asking_for_aggregates_to_snapshot_spec.rb +0 -66
  31. data/spec/saving_snapshot_spec.rb +0 -69
  32. data/spec/snapshot_access_spec.rb +0 -110
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afdf98e380414f253698243d6c774c0ee744f01c
4
- data.tar.gz: 0a47f12826b1009ac40f7425f63040f91aeba81a
3
+ metadata.gz: 733436ed1a28c227cd7f4af61f0e988d3596d4cc
4
+ data.tar.gz: 3fb7675715543044914b2490a5322855d4d3163b
5
5
  SHA512:
6
- metadata.gz: 684d556c1a96bcad5a8a471e2d4f3ef470f7f2db40f4cf37af8f1f491c102ed9c32ad5c06fad652817927b17cfbf82ffe26ead0aae01305e69aa9f04c35a8c6b
7
- data.tar.gz: 9e4f1345797c3d9906f66cfc056f2a971b6e17c9d303ba080a4db850ae545a8ab2de1b9454ced03609369d609e3a81c7a216242432a98142c2ed3758123d1c7d
6
+ metadata.gz: 1b8bdba85c255968f5c076780ee5f2de0ade21168d91ad3e45c8b2ee965d3c5b1fe14cb23cb3460bf4ee4b3dad2dd0b5ceb1cd59e8223e542e709cfee5e8ede7
7
+ data.tar.gz: 9850c19545a557071a6bb616d08e2d01fdfd281db913e41d1de1cf4c9ccfe5aa79f31b05a8eae2df3c3f9c86555c13e3fa98ba41d120f674f9cedbb1fa5269e1
data/README.md CHANGED
@@ -22,16 +22,14 @@ Or install it yourself as:
22
22
 
23
23
  ### `SandthornDriverSequel.configure`
24
24
 
25
- Change the global configuration, the default data serialization for events and snapshots are YAML.
25
+ Change the global configuration, the default data serialization for events are YAML.
26
26
 
27
- Change the serialization of events and snapshots to Oj.
27
+ Change the serialization of events to Oj.
28
28
 
29
29
  ```ruby
30
30
  SandthornDriverSequel.configure { |conf|
31
31
  conf.event_serializer = Proc.new { |data| Oj::dump(data) }
32
32
  conf.event_deserializer = Proc.new { |data| Oj::load(data) }
33
- conf.snapshot_serializer = Proc.new { |data| Oj::dump(data) }
34
- conf.snapshot_deserializer = Proc.new { |data| Oj::dump(data) }
35
33
  }
36
34
  ```
37
35
 
@@ -34,10 +34,6 @@ module SandthornDriverSequel
34
34
  aggregate
35
35
  end
36
36
 
37
- def aggregate_types
38
- storage.aggregates.select(:aggregate_type).distinct.select_map(:aggregate_type)
39
- end
40
-
41
37
  # Returns aggregate ids.
42
38
  # @param aggregate_type, optional,
43
39
  def aggregate_ids(aggregate_type: nil)
@@ -23,7 +23,7 @@ module SandthornDriverSequel
23
23
  def find_events_by_aggregate_id(aggregate_id)
24
24
  aggregate_version = Sequel.qualify(storage.events_table_name, :aggregate_version)
25
25
  wrap(storage.events
26
- .join(storage.aggregates, id: :aggregate_table_id)
26
+ .join(storage.aggregates_table_name, id: :aggregate_table_id)
27
27
  .where(aggregate_id: aggregate_id)
28
28
  .select(
29
29
  :sequence_number,
@@ -32,20 +32,12 @@ module SandthornDriverSequel
32
32
  aggregate_version,
33
33
  :event_name,
34
34
  :event_data,
35
+ :event_metadata,
35
36
  :timestamp)
36
37
  .order(:sequence_number)
37
38
  .all)
38
39
  end
39
40
 
40
- # Returns events that occurred after the given snapshot
41
- def after_snapshot(snapshot)
42
- _aggregate_version = snapshot.aggregate_version
43
- aggregate_table_id = snapshot.aggregate_table_id
44
- wrap(storage.events
45
- .where(aggregate_table_id: aggregate_table_id)
46
- .where { aggregate_version > _aggregate_version }.all)
47
- end
48
-
49
41
  def get_events(*args)
50
42
  query_builder = EventQuery.new(storage)
51
43
  query_builder.build(*args)
@@ -56,16 +48,19 @@ module SandthornDriverSequel
56
48
 
57
49
  def wrap(arg)
58
50
  events = Utilities.array_wrap(arg)
59
- events.each { |e| e[:event_args] = deserialize(e[:event_data]) }
51
+ events.each { |e|
52
+ e[:event_data] = deserialize(e[:event_data])
53
+ e[:event_metadata] = deserialize(e[:event_metadata])
54
+ }
60
55
  events.map { |e| EventWrapper.new(e.values) }
61
56
  end
62
57
 
63
58
  def deserialize event_data
64
- @deserializer.call(event_data)
59
+ event_data ? @deserializer.call(event_data) : nil
65
60
  end
66
61
 
67
- def serialize event_args
68
- @serializer.call(event_args)
62
+ def serialize event_data
63
+ @serializer.call(event_data)
69
64
  end
70
65
 
71
66
  def build_event_data(aggregate, timestamp, event)
@@ -73,7 +68,8 @@ module SandthornDriverSequel
73
68
  aggregate_table_id: aggregate.id,
74
69
  aggregate_version: aggregate.aggregate_version,
75
70
  event_name: event.event_name,
76
- event_data: serialize(event.event_args),
71
+ event_data: serialize(event.event_data),
72
+ event_metadata: serialize(event.event_metadata),
77
73
  timestamp: timestamp
78
74
  }
79
75
  end
@@ -32,18 +32,4 @@ module SandthornDriverSequel::Errors
32
32
  end
33
33
  end
34
34
 
35
- class WrongSnapshotVersionError < Error
36
- attr_reader :aggregate, :version
37
- def initialize(aggregate, version)
38
- @aggregate = aggregate
39
- @version = version
40
- super(create_message)
41
- end
42
-
43
- def create_message
44
- "#{aggregate[:aggregate_type]} with id #{aggregate[:aggregate_id]}: tried to save snapshot with version "+
45
- "#{version}, but current version is at #{aggregate[:aggregate_version]}"
46
- end
47
- end
48
-
49
35
  end
@@ -48,6 +48,7 @@ module SandthornDriverSequel
48
48
  :sequence_number,
49
49
  :event_name,
50
50
  :event_data,
51
+ :event_metadata,
51
52
  :timestamp
52
53
  ]
53
54
  end
@@ -58,9 +59,9 @@ module SandthornDriverSequel
58
59
 
59
60
  def add_aggregate_types(query, aggregate_types)
60
61
  if aggregate_types.any?
61
- query.join(storage.aggregates, id: :aggregate_table_id, aggregate_type: aggregate_types)
62
+ query.join(storage.aggregates_table_name, id: :aggregate_table_id, aggregate_type: aggregate_types)
62
63
  else
63
- query.join(storage.aggregates, id: :aggregate_table_id)
64
+ query.join(storage.aggregates_table_name, id: :aggregate_table_id)
64
65
  end
65
66
  end
66
67
 
@@ -1,6 +1,5 @@
1
1
  require "sandthorn_driver_sequel/access/aggregate_access"
2
2
  require "sandthorn_driver_sequel/access/event_access"
3
- require "sandthorn_driver_sequel/access/snapshot_access"
4
3
  require "sandthorn_driver_sequel/storage"
5
4
 
6
5
  module SandthornDriverSequel
@@ -14,8 +13,6 @@ module SandthornDriverSequel
14
13
  @context = context
15
14
  @event_serializer = configuration.event_serializer
16
15
  @event_deserializer = configuration.event_deserializer
17
- @snapshot_serializer = configuration.snapshot_serializer
18
- @snapshot_deserializer = configuration.snapshot_deserializer
19
16
  end
20
17
 
21
18
  def self.from_url url, configuration, context = nil
@@ -32,61 +29,33 @@ module SandthornDriverSequel
32
29
  end
33
30
  end
34
31
 
35
- def save_snapshot aggregate
36
- driver.execute_in_transaction do |db|
37
- snapshot_access = get_snapshot_access(db)
38
- snapshot_access.record_snapshot(aggregate)
39
- end
40
- end
41
-
42
32
  #get methods
43
33
  def all aggregate_type
44
34
  return get_aggregate_ids(aggregate_type: aggregate_type).map do |id|
45
- get_aggregate_events_from_snapshot(id)
35
+ aggregate_events(id)
46
36
  end
47
37
  end
48
38
 
49
- def find aggregate_id
50
- get_aggregate_events_from_snapshot(aggregate_id)
39
+ def find aggregate_id, aggregate_type
40
+ aggregate_events(aggregate_id)
51
41
  end
52
42
 
53
-
54
- def get_aggregate_events(aggregate_id)
43
+ def get_events(*args)
55
44
  driver.execute do |db|
56
- events = get_event_access(db)
57
- events.find_events_by_aggregate_id(aggregate_id)
45
+ event_access = get_event_access(db)
46
+ event_access.get_events(*args)
58
47
  end
59
48
  end
60
49
 
61
- # If the aggregate has a snapshot, return events starting from the snapshots.
62
- # Otherwise, return all events.
63
- # TODO: needs a better name
64
- def get_aggregate_events_from_snapshot(aggregate_id)
50
+ private
51
+
52
+ def aggregate_events(aggregate_id)
65
53
  driver.execute do |db|
66
- snapshots = get_snapshot_access(db)
67
54
  event_access = get_event_access(db)
68
- snapshot = snapshots.find_by_aggregate_id(aggregate_id)
69
- if snapshot
70
- events = event_access.after_snapshot(snapshot)
71
- snapshot_event = build_snapshot_event(snapshot)
72
- events.unshift(snapshot_event)
73
- else
74
- event_access.find_events_by_aggregate_id(aggregate_id)
75
- end
55
+ event_access.find_events_by_aggregate_id(aggregate_id)
76
56
  end
77
57
  end
78
58
 
79
-
80
-
81
-
82
-
83
- def get_aggregate aggregate_id, *class_name
84
- warn(":get_aggregate is deprecated. Use :get_aggregate_events_from_snapshot")
85
- get_aggregate_events_from_snapshot(aggregate_id)
86
- end
87
-
88
-
89
-
90
59
  def get_aggregate_ids(aggregate_type: nil)
91
60
  driver.execute do |db|
92
61
  access = get_aggregate_access(db)
@@ -94,59 +63,6 @@ module SandthornDriverSequel
94
63
  end
95
64
  end
96
65
 
97
- def get_aggregate_list_by_typename(type)
98
- warn(":get_aggregate_list_by_typenames is deprecated. Use :get_aggregate_ids")
99
- get_aggregate_ids(aggregate_type: type)
100
- end
101
-
102
- def get_all_types
103
- driver.execute do |db|
104
- access = get_aggregate_access(db)
105
- access.aggregate_types
106
- end
107
- end
108
-
109
- def get_snapshot aggregate_id
110
- driver.execute do |db|
111
- snapshots = get_snapshot_access(db)
112
- snapshot = snapshots.find_by_aggregate_id(aggregate_id)
113
- snapshot.data
114
- end
115
- end
116
-
117
- def get_events(*args)
118
- driver.execute do |db|
119
- event_access = get_event_access(db)
120
- event_access.get_events(*args)
121
- end
122
- end
123
-
124
- def get_new_events_after_event_id_matching_classname event_id, class_name, take: 0
125
- get_events(after_sequence_number: event_id, aggregate_types: Utilities.array_wrap(class_name), take: take)
126
- end
127
-
128
- def obsolete_snapshots(*args)
129
- driver.execute do |db|
130
- snapshots = get_snapshot_access(db)
131
- snapshots.obsolete(*args)
132
- end
133
- end
134
-
135
- private
136
-
137
- def build_snapshot_event(snapshot)
138
- {
139
- aggregate: snapshot.data,
140
- }
141
- end
142
-
143
- def transform_snapshot(snapshot)
144
- {
145
- aggregate_version: snapshot.aggregate_version,
146
- event_data: snapshot.snapshot_data
147
- }
148
- end
149
-
150
66
  def get_aggregate_access(db)
151
67
  @aggregate_access ||= AggregateAccess.new(storage(db))
152
68
  end
@@ -155,10 +71,6 @@ module SandthornDriverSequel
155
71
  @event_access ||= EventAccess.new(storage(db), @event_serializer, @event_deserializer)
156
72
  end
157
73
 
158
- def get_snapshot_access(db)
159
- @snapshot_access ||= SnapshotAccess.new(storage(db), @snapshot_serializer, @snapshot_deserializer)
160
- end
161
-
162
74
  def storage(db)
163
75
  @storage ||= Storage.new(db, @context)
164
76
  end
@@ -1,15 +1,15 @@
1
1
  module SandthornDriverSequel
2
2
  module EventStoreContext
3
3
  attr_reader :context
4
+
4
5
  def events_table_name
5
6
  with_context_if_exists :events
6
7
  end
8
+
7
9
  def aggregates_table_name
8
10
  with_context_if_exists :aggregates
9
11
  end
10
- def snapshots_table_name
11
- with_context_if_exists :snapshots
12
- end
12
+
13
13
  def with_context_if_exists name
14
14
  name = "#{context}_#{name}".to_sym if context
15
15
  name
@@ -17,7 +17,6 @@ module SandthornDriverSequel
17
17
  private
18
18
  def clear_for_test
19
19
  driver.execute do |db|
20
- db[snapshots_table_name].truncate
21
20
  db[events_table_name].truncate
22
21
  db[aggregates_table_name].truncate
23
22
  end
@@ -77,13 +76,23 @@ module SandthornDriverSequel
77
76
  was_migrated events_migration_1, db
78
77
  end
79
78
  end
79
+
80
+ events_migration_2 = "#{events_table_name}-20170514"
81
+ unless has_been_migrated?(events_migration_2)
82
+ driver.execute_in_transaction do |db|
83
+ db.alter_table events_table_name do
84
+ add_column :event_metadata, String, text: true, null: true
85
+ end
86
+ was_migrated events_migration_2, db
87
+ end
88
+ end
80
89
  end
81
90
  def snapshots
82
- snapshot_migration_0 = "#{snapshots_table_name}-20130312"
91
+ snapshot_migration_0 = "#{:snapshots}-20130312"
83
92
  unless has_been_migrated?(snapshot_migration_0)
84
93
  driver.execute_in_transaction do |db|
85
94
  aggr_table = aggregates_table_name
86
- db.create_table(snapshots_table_name) do
95
+ db.create_table(:snapshots) do
87
96
  primary_key :id
88
97
  Integer :aggregate_version, null: false
89
98
  String :snapshot_data, text: true, null: false
@@ -93,6 +102,14 @@ module SandthornDriverSequel
93
102
  was_migrated snapshot_migration_0, db
94
103
  end
95
104
  end
105
+ snapshot_migration_1 = "#{:snapshots}-20170416"
106
+ unless has_been_migrated?(snapshot_migration_1)
107
+ driver.execute_in_transaction do |db|
108
+ db.drop_table?(:snapshots)
109
+ was_migrated snapshot_migration_1, db
110
+ end
111
+
112
+ end
96
113
  end
97
114
 
98
115
  def migration_table_name
@@ -25,11 +25,6 @@ module SandthornDriverSequel
25
25
  Class.new(Sequel::Model(events_table))
26
26
  end
27
27
 
28
- # Returns a Sequel::Model for accessing snapshots
29
- def snapshots
30
- Class.new(Sequel::Model(snapshots_table))
31
- end
32
-
33
28
  def aggregates_table
34
29
  db[aggregates_table_name]
35
30
  end
@@ -38,9 +33,5 @@ module SandthornDriverSequel
38
33
  db[events_table_name]
39
34
  end
40
35
 
41
- def snapshots_table
42
- db[snapshots_table_name]
43
- end
44
-
45
36
  end
46
37
  end
@@ -1,3 +1,3 @@
1
1
  module SandthornDriverSequel
2
- VERSION = "3.2.1"
2
+ VERSION = "4.0.0"
3
3
  end
@@ -2,7 +2,7 @@ require 'delegate'
2
2
  module SandthornDriverSequel
3
3
  class EventWrapper < SimpleDelegator
4
4
 
5
- [:aggregate_version, :event_name, :event_data, :event_args, :timestamp, :aggregate_table_id].each do |attribute|
5
+ [:aggregate_version, :event_name, :event_data, :event_metadata, :timestamp, :aggregate_table_id].each do |attribute|
6
6
  define_method(attribute) do
7
7
  fetch(attribute)
8
8
  end
@@ -1,2 +1 @@
1
1
  require "sandthorn_driver_sequel/wrappers/event_wrapper"
2
- require "sandthorn_driver_sequel/wrappers/snapshot_wrapper"
@@ -83,32 +83,6 @@ module SandthornDriverSequel
83
83
  -> (data) { YAML.load(data) }
84
84
  end
85
85
 
86
- #snapshot
87
- def snapshot_serializer=(block)
88
- @snapshot_serializer = block
89
- end
90
-
91
- def snapshot_deserializer=(block)
92
- @snapshot_deserializer = block
93
- end
94
-
95
- def snapshot_serializer
96
- @snapshot_serializer || default_snapshot_serializer
97
- end
98
-
99
- def snapshot_deserializer
100
- @snapshot_deserializer || default_snapshot_deserializer
101
- end
102
-
103
- def default_snapshot_serializer
104
- -> (data) { YAML.dump(data) }
105
- end
106
-
107
- def default_snapshot_deserializer
108
- -> (data) { YAML.load(data) }
109
- end
110
-
111
-
112
86
  end
113
87
  end
114
88
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "rake"
25
25
 
26
26
  spec.add_development_dependency "rspec"
@@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "autotest-standalone"
33
33
  spec.add_development_dependency "uuidtools"
34
34
  spec.add_development_dependency "ruby-beautify"
35
- spec.add_development_dependency "guard-rspec"
36
35
 
37
- spec.add_runtime_dependency "sequel", "~> 4.17"
36
+ spec.add_runtime_dependency "sequel"
38
37
  end
@@ -62,16 +62,6 @@ module SandthornDriverSequel
62
62
  end
63
63
  end
64
64
 
65
- describe "#aggregate_types" do
66
- it "returns all aggregate types in the event store" do
67
- types = ["foo", "bar", "qux"]
68
- types.each do |type|
69
- access.register_aggregate(generate_uuid, type)
70
- end
71
- expect(access.aggregate_types).to eq(types.sort)
72
- end
73
- end
74
-
75
65
  describe "#aggregate_ids" do
76
66
  context "when given no argument" do
77
67
  it "returns all aggregate ids" do
@@ -10,20 +10,20 @@ module Sandthorn
10
10
  before(:each) { prepare_for_test }
11
11
  let(:test_events_20_events) do
12
12
  e = []
13
- e << {aggregate_version: 1, event_name: "new", event_args: {:method_name=>"new", :method_args=>[], :attribute_deltas=>[{:attribute_name=>"aggregate_id", :old_value=>nil, :new_value=>"0a74e545-be84-4506-8b0a-73e947856327"}]}}
13
+ e << {aggregate_version: 1, event_name: "new", event_data: {:attribute_deltas=>[{:attribute_name=>"aggregate_id", :old_value=>nil, :new_value=>"0a74e545-be84-4506-8b0a-73e947856327"}]}}
14
14
  19.times do |i|
15
- e << {aggregate_version: i+2, event_name: "foo", event_args: "A2"}
15
+ e << {aggregate_version: i+2, event_name: "foo", event_data: "A2"}
16
16
  end
17
17
  e
18
18
  end
19
19
  let(:test_events_one_event) do
20
20
  e = []
21
- e << {aggregate_version: 1, event_name: "new", event_args: "B1" }
21
+ e << {aggregate_version: 1, event_name: "new", event_data: "B1" }
22
22
  end
23
23
  let(:test_events_two_events) do
24
24
  e = []
25
- e << {aggregate_version: 1, event_name: "new", event_args: {:method_name=>"new", :method_args=>[], :attribute_deltas=>[{:attribute_name=>"aggregate_id", :old_value=>nil, :new_value=>"0a74e545-be84-4506-8b0a-73e947856327"}]}}
26
- e << {aggregate_version: 2, event_name: "foo", event_args: "A2"}
25
+ e << {aggregate_version: 1, event_name: "new", event_data: {:attribute_deltas=>[{:attribute_name=>"aggregate_id", :old_value=>nil, :new_value=>"0a74e545-be84-4506-8b0a-73e947856327"}]}}
26
+ e << {aggregate_version: 2, event_name: "foo", event_data: "A2"}
27
27
  end
28
28
  let(:aggregate_id) {"c0456e26-2345-4f67-92fa-130b3a31a39a"}
29
29
  let(:es) { event_store }
@@ -72,36 +72,7 @@ module Sandthorn
72
72
  end
73
73
 
74
74
  end
75
- describe "find with snapshot" do
76
-
77
- it "should find one event that is snapshoted 500 times" do
78
- snapshot_data = { event_data: YAML.dump(Object.new), aggregate_version: 1 }
79
- es.save_events(test_events_one_event, 0, aggregate_id, SandthornDriverSequel::EventStore)
80
- es.save_snapshot(snapshot_data, aggregate_id, SandthornDriverSequel::EventStore)
81
-
82
- Benchmark.bm do |x|
83
- x.report("find") { for i in 1..n; es.get_aggregate(aggregate_id, SandthornDriverSequel::EventStore); end }
84
- end
85
- end
86
- it "should find two events that is snapshoted 500 times" do
87
- snapshot_data = { event_data: YAML.dump(Object.new), aggregate_version: 2 }
88
- es.save_events(test_events_two_events, 0, aggregate_id, SandthornDriverSequel::EventStore)
89
- es.save_snapshot(snapshot_data, aggregate_id, SandthornDriverSequel::EventStore)
90
- Benchmark.bm do |x|
91
- x.report("find") { for i in 1..n; es.get_aggregate(aggregate_id, SandthornDriverSequel::EventStore); end }
92
- end
93
- end
94
- it "should find twenty events that is snapshoted 500 times" do
95
- snapshot_data = { event_data: YAML.dump(Object.new), aggregate_version: 19 }
96
- es.save_events(test_events_20_events, 0, aggregate_id, SandthornDriverSequel::EventStore)
97
- es.save_snapshot(snapshot_data, aggregate_id, SandthornDriverSequel::EventStore)
98
-
99
- Benchmark.bm do |x|
100
- x.report("find") { for i in 1..n; es.get_aggregate(aggregate_id, SandthornDriverSequel::EventStore); end }
101
- end
102
- end
103
-
104
- end
75
+
105
76
  # it "new save and find 500 aggregates" do
106
77
 
107
78
  # Benchmark.bm do |x|
@@ -19,21 +19,11 @@ module SandthornDriverSequel
19
19
  expect(driver.instance_variable_get "@event_deserializer".to_sym).to be_a Proc
20
20
  end
21
21
 
22
- it "should have the default snapshot_serializer" do
23
- expect(driver.instance_variable_get "@snapshot_serializer".to_sym).to be_a Proc
24
- end
25
-
26
- it "should have the default snapshot_deserializer" do
27
- expect(driver.instance_variable_get "@snapshot_deserializer".to_sym).to be_a Proc
28
- end
29
-
30
22
  context "change global configuration" do
31
23
  before do
32
24
  SandthornDriverSequel.configure { |conf|
33
25
  conf.event_serializer = :serializer_event_global
34
26
  conf.event_deserializer = :deserializer_event_global
35
- conf.snapshot_serializer = :serializer_snapshot_global
36
- conf.snapshot_deserializer = :deserializer_snapshot_global
37
27
  }
38
28
  end
39
29
 
@@ -42,8 +32,6 @@ module SandthornDriverSequel
42
32
  SandthornDriverSequel.configure { |conf|
43
33
  conf.event_serializer = -> (data) { YAML.dump(data) }
44
34
  conf.event_deserializer = -> (data) { YAML.load(data) }
45
- conf.snapshot_serializer = -> (data) { YAML.dump(data) }
46
- conf.snapshot_deserializer = -> (data) { YAML.load(data) }
47
35
  }
48
36
  end
49
37
 
@@ -55,13 +43,6 @@ module SandthornDriverSequel
55
43
  expect(driver.instance_variable_get "@event_deserializer".to_sym).to eql :deserializer_event_global
56
44
  end
57
45
 
58
- it "should have the new snapshot_serializer" do
59
- expect(driver.instance_variable_get "@snapshot_serializer".to_sym).to eql :serializer_snapshot_global
60
- end
61
-
62
- it "should have the default snapshot_deserializer" do
63
- expect(driver.instance_variable_get "@snapshot_deserializer".to_sym).to eql :deserializer_snapshot_global
64
- end
65
46
  end
66
47
  end
67
48
 
@@ -70,8 +51,6 @@ module SandthornDriverSequel
70
51
  SandthornDriverSequel.driver_from_connection(connection: Sequel.sqlite) { |conf|
71
52
  conf.event_serializer = :event_serializer
72
53
  conf.event_deserializer = :event_deserializer
73
- conf.snapshot_serializer = :snapshot_serializer
74
- conf.snapshot_deserializer = :snapshot_deserializer
75
54
  }
76
55
  end
77
56
 
@@ -87,14 +66,6 @@ module SandthornDriverSequel
87
66
  expect(driver.instance_variable_get "@event_deserializer".to_sym).to eql :event_deserializer
88
67
  end
89
68
 
90
- it "should have a configuration snapshot_serializer" do
91
- expect(driver.instance_variable_get "@snapshot_serializer".to_sym).to eql :snapshot_serializer
92
- end
93
-
94
- it "should have a configuration snapshot_deserializer" do
95
- expect(driver.instance_variable_get "@snapshot_deserializer".to_sym).to eql :snapshot_deserializer
96
- end
97
-
98
69
  end
99
70
 
100
71
 
@@ -7,13 +7,6 @@ module SandthornDriverSequel
7
7
  let(:subject) { event_store }
8
8
  methods = [
9
9
  :save_events,
10
- :save_snapshot,
11
- :get_aggregate_events_from_snapshot,
12
- :get_aggregate,
13
- :get_aggregate_events,
14
- :get_aggregate_ids,
15
- :get_all_types,
16
- :get_snapshot,
17
10
  :get_events,
18
11
  :context,
19
12
  :driver,