nexia_event_store 0.7.2 → 0.7.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a99ede0e343cb9afe0641ccf0f97b6ede6d94c1d
4
- data.tar.gz: 356728b39664676f69f18b719efdf1bb3561d865
3
+ metadata.gz: ffd113debea7c43b5fb12395152ffe02ca41d163
4
+ data.tar.gz: dc82ef5757b0dbdf922cc6201644f65e8a7a0696
5
5
  SHA512:
6
- metadata.gz: 4638a89824d357ff595cf365cb675cd3f9fc11caf30fadeb10b25e5079a6ca510837fa67a92d3f75e19688fdaec53db7c3ff914e426c224a8718168d6b12b8f2
7
- data.tar.gz: 81ccbaa007f95d930d9b00e94924a77a5c2517c8c13ff63629052c74329c20254d02002f8a5f9182aaf35833b3a11b2333689887751444618c5b3be5f8c9a795
6
+ metadata.gz: 8555901466c29f480c9f494111ef015d7ebad9a83df37aa921a83a4e585a662bd22f56d17bffce79e5f58c9404b21dad67aa7b48f0f7c936e33595e254643604
7
+ data.tar.gz: 7928d2a5cc33e70888b6f71d363327309bfce4c0aa88245be4158b75f756598a74dfa2fe609ba39ea7878761643a28f33017453e058cfb8081ae1139ac91a114
@@ -42,9 +42,11 @@ module EventStore
42
42
  @event_stream = EventStream.new(self)
43
43
  end
44
44
 
45
- def append(events)
46
- event_stream.append(events) do |prepared_events|
47
- snapshot.store_snapshot(prepared_events)
45
+ def append(events, logger)
46
+ logger.debug { "EventStore#append, appending to event stream" }
47
+ event_stream.append(events, logger) do |prepared_events|
48
+ logger.debug { "EventStore#append, storing snapshot" }
49
+ snapshot.store_snapshot(prepared_events, logger)
48
50
  end
49
51
  end
50
52
 
@@ -32,7 +32,7 @@ module EventStore
32
32
 
33
33
  def append(event_data, logger=default_logger)
34
34
  logger.debug("Start Appending #{event_data} to #{id}")
35
- aggregate.append(event_data)
35
+ aggregate.append(event_data, logger)
36
36
  logger.debug("Done Appending #{event_data} to #{id}")
37
37
  yield(event_data) if block_given?
38
38
  nil
@@ -13,7 +13,7 @@ module EventStore
13
13
  @names_table = EventStore.fully_qualified_names_table
14
14
  end
15
15
 
16
- def append(raw_events)
16
+ def append(raw_events, logger)
17
17
  prepared_events = raw_events.map do |raw_event|
18
18
  event = prepare_event(raw_event)
19
19
  ensure_all_attributes_have_values!(event)
@@ -31,6 +31,8 @@ module EventStore
31
31
  id = event_table.insert(event_hash)
32
32
  end
33
33
 
34
+ logger.debug { "EventStream#append, setting id #{id} for #{event_hash.inspect}" }
35
+
34
36
  event[:id] = id
35
37
  end
36
38
 
@@ -72,18 +72,25 @@ module EventStore
72
72
  EventStore.redis.del [snapshot_table, snapshot_event_id_table]
73
73
  end
74
74
 
75
- def store_snapshot(prepared_events)
75
+ def store_snapshot(prepared_events, logger=default_logger)
76
76
  valid_snapshot_events = []
77
77
  valid_snapshot_event_ids = []
78
78
 
79
79
  prepared_events.each do |event_hash|
80
- if event_hash[:id].to_i > current_event_id_numbers[snapshot_key(event_hash)].to_i
80
+ key = snapshot_key(event_hash)
81
+ current_id = current_event_id_numbers[key].to_i
82
+
83
+ logger.debug { "Snapshot#store_snapshot: snapshot_key: #{key} prepared id: #{event_hash[:id]}, current id: #{current_id}" }
84
+ if event_hash[:id].to_i > current_id
85
+ logger.debug { "prepared event is newer, storing" }
81
86
  valid_snapshot_events += snapshot_event(event_hash)
82
87
  valid_snapshot_event_ids += snapshot_event_id(event_hash)
83
88
  end
84
89
  end
85
90
 
91
+ logger.debug { "valid_snapshot_event_ids: #{valid_snapshot_event_ids.inspect}" }
86
92
  unless valid_snapshot_event_ids.empty?
93
+ logger.debug { "there are valid_snapshot_event_ids, persisting to redis" }
87
94
  valid_snapshot_event_ids += [:current_event_id, valid_snapshot_event_ids.last.to_i]
88
95
 
89
96
  @redis.multi do
@@ -1,3 +1,3 @@
1
1
  module EventStore
2
- VERSION = '0.7.2'
2
+ VERSION = '0.7.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexia_event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Saieg, John Colvin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-12 00:00:00.000000000 Z
12
+ date: 2015-06-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  version: '0'
234
234
  requirements: []
235
235
  rubyforge_project:
236
- rubygems_version: 2.4.5
236
+ rubygems_version: 2.4.3
237
237
  signing_key:
238
238
  specification_version: 4
239
239
  summary: Ruby implementation of an EventSource (A+ES) for the Nexia Ecosystem