nexia_event_store 0.7.5 → 0.8.0
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 +4 -4
- data/lib/event_store.rb +20 -1
- data/lib/event_store/event_stream.rb +9 -1
- data/lib/event_store/version.rb +1 -1
- data/spec/event_store/client_spec.rb +10 -10
- data/spec/event_store/event_store_spec.rb +27 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0482c47fcd18e73eb1faaddc9762fc4d7315c023
|
4
|
+
data.tar.gz: 2300cc30c2e1c37bdfc4b9fe98cc96f015914655
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77cb1a1695d9f3d1e61ef508fba5ca4c435a9194a538595a4fc995c35a8593ac634d56efb2bad6c673658448a4aac9a1c65eb4d9036100a209a9b2a711b75505
|
7
|
+
data.tar.gz: 14b00a3904376be51d2d7a8702c9a84ca7ea07d9360d9a7b130547475dc7e3514966ba946fd803b9dcaa749be633ece6eee7a0475b9bfb4e059eaa12939cb891
|
data/lib/event_store.rb
CHANGED
@@ -60,6 +60,21 @@ module EventStore
|
|
60
60
|
@schema ||= raw_db_config[@environment][@adapter]['schema']
|
61
61
|
end
|
62
62
|
|
63
|
+
def self.insert_table_name(date)
|
64
|
+
return fully_qualified_table unless partitioning?
|
65
|
+
|
66
|
+
partition_name = date.strftime("#{table_name}#{partition_name_suffix}")
|
67
|
+
qualified_table_name(partition_name)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.partitioning?
|
71
|
+
@db_config["partitioning"]
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.partition_name_suffix
|
75
|
+
@db_config["partition_name_suffix"]
|
76
|
+
end
|
77
|
+
|
63
78
|
def self.table_name
|
64
79
|
@table_name ||= raw_db_config['table_name']
|
65
80
|
end
|
@@ -69,7 +84,11 @@ module EventStore
|
|
69
84
|
end
|
70
85
|
|
71
86
|
def self.fully_qualified_table
|
72
|
-
@fully_qualified_table ||=
|
87
|
+
@fully_qualified_table ||= qualified_table_name
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.qualified_table_name(name = table_name)
|
91
|
+
Sequel.lit "#{schema}.#{name}"
|
73
92
|
end
|
74
93
|
|
75
94
|
def self.fully_qualified_names_table
|
@@ -21,9 +21,9 @@ module EventStore
|
|
21
21
|
event
|
22
22
|
end
|
23
23
|
|
24
|
-
event_table = EventStore.db.from(@event_table)
|
25
24
|
prepared_events.each do |event|
|
26
25
|
event_hash = event.dup.reject! { |k,v| k == :fully_qualified_name }
|
26
|
+
event_table = insert_table(event_hash[:occurred_at])
|
27
27
|
|
28
28
|
begin
|
29
29
|
id = event_table.insert(event_hash)
|
@@ -40,6 +40,14 @@ module EventStore
|
|
40
40
|
yield(prepared_events) if block_given?
|
41
41
|
end
|
42
42
|
|
43
|
+
def insert_table(occurred_at)
|
44
|
+
EventStore.db.from(insert_table_name(occurred_at))
|
45
|
+
end
|
46
|
+
|
47
|
+
def insert_table_name(date)
|
48
|
+
EventStore.insert_table_name(date)
|
49
|
+
end
|
50
|
+
|
43
51
|
def fully_qualified_names
|
44
52
|
@fully_qualified_name_query ||= EventStore.db.from(@names_table)
|
45
53
|
end
|
data/lib/event_store/version.rb
CHANGED
@@ -267,21 +267,21 @@ describe EventStore::Client do
|
|
267
267
|
client.append([old_event])
|
268
268
|
end
|
269
269
|
|
270
|
-
it "
|
270
|
+
it "appends a single event of a new type without raising an error" do
|
271
271
|
initial_count = client.count
|
272
272
|
events = [new_event]
|
273
273
|
client.append(events)
|
274
274
|
expect(client.count).to eq(initial_count + events.length)
|
275
275
|
end
|
276
276
|
|
277
|
-
it "
|
277
|
+
it "appends multiple events of a new type without raising and error" do
|
278
278
|
initial_count = client.count
|
279
279
|
events = [new_event, new_event]
|
280
280
|
client.append(events)
|
281
281
|
expect(client.count).to eq(initial_count + events.length)
|
282
282
|
end
|
283
283
|
|
284
|
-
it "
|
284
|
+
it "changes the event id number" do
|
285
285
|
events = [new_event, really_new_event]
|
286
286
|
expect{ client.append(events) }.to change(client, :event_id)
|
287
287
|
end
|
@@ -293,7 +293,7 @@ describe EventStore::Client do
|
|
293
293
|
expect(client.snapshot.event_id).to eq(client.raw_event_stream.last[:id])
|
294
294
|
end
|
295
295
|
|
296
|
-
it "
|
296
|
+
it "writes through cache the event in a snapshot without duplicating events" do
|
297
297
|
client.destroy!
|
298
298
|
client.append([old_event, new_event, new_event])
|
299
299
|
expected = []
|
@@ -302,7 +302,7 @@ describe EventStore::Client do
|
|
302
302
|
expect(client.snapshot.to_a).to eq(expected)
|
303
303
|
end
|
304
304
|
|
305
|
-
it "
|
305
|
+
it "raises a meaningful exception when a nil event given to it to append" do
|
306
306
|
expect {client.append([nil])}.to raise_exception(ArgumentError)
|
307
307
|
end
|
308
308
|
end
|
@@ -312,12 +312,12 @@ describe EventStore::Client do
|
|
312
312
|
client.append([old_event])
|
313
313
|
end
|
314
314
|
|
315
|
-
it "
|
315
|
+
it "does not raise an error when two events of the same type are appended" do
|
316
316
|
client.append([duplicate_event])
|
317
317
|
client.append([duplicate_event]) #will fail automatically if it throws an error, no need for assertions (which now print warning for some reason)
|
318
318
|
end
|
319
319
|
|
320
|
-
it "
|
320
|
+
it "writes-through-cache the event in a snapshot without duplicating events" do
|
321
321
|
client.destroy!
|
322
322
|
client.append([old_event, new_event, new_event])
|
323
323
|
expected = []
|
@@ -341,7 +341,7 @@ describe EventStore::Client do
|
|
341
341
|
@bad_event.fully_qualified_name = nil
|
342
342
|
end
|
343
343
|
|
344
|
-
it "
|
344
|
+
it "reverts all append events if one fails" do
|
345
345
|
starting_count = client.count
|
346
346
|
expect { client.append([new_event, @bad_event]) }.to raise_error(EventStore::AttributeMissingError)
|
347
347
|
expect(client.count).to eq(starting_count)
|
@@ -353,13 +353,13 @@ describe EventStore::Client do
|
|
353
353
|
expect(x).to eq(0)
|
354
354
|
end
|
355
355
|
|
356
|
-
it "
|
356
|
+
it "yields to the block after event creation" do
|
357
357
|
x = 0
|
358
358
|
client.append([]) { x += 1 }
|
359
359
|
expect(x).to eq(1)
|
360
360
|
end
|
361
361
|
|
362
|
-
it "
|
362
|
+
it "passes the raw event_data to the block" do
|
363
363
|
client.append([new_event]) do |raw_event_data|
|
364
364
|
expect(raw_event_data).to eq([new_event])
|
365
365
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe EventStore do
|
4
|
+
describe ".insert_table_name" do
|
5
|
+
let(:date) { Date.parse("1955-01-31") }
|
6
|
+
|
7
|
+
context "without partitioning defined" do
|
8
|
+
let(:expected) { "es_test.test_events" }
|
9
|
+
|
10
|
+
it "returns a properly formatted default table name" do
|
11
|
+
expect(subject.insert_table_name(date)).to eq(expected)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with partitioning defined" do
|
16
|
+
let(:expected) { "es_test.test_events_1955_01_31" }
|
17
|
+
let(:partition_config) { { "schema" => "es_test", "partition_name_suffix" => "_%Y_%m_%d", "partitioning" => true } }
|
18
|
+
|
19
|
+
before { subject.custom_config(partition_config, subject.local_redis_config, "test_events", "test") }
|
20
|
+
after { subject.custom_config(subject.raw_db_config["test"]["postgres"], subject.local_redis_config, "test_events", "test") }
|
21
|
+
|
22
|
+
it "returns a properly formatted table name" do
|
23
|
+
expect(subject.insert_table_name(date)).to eq(expected)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
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.
|
4
|
+
version: 0.8.0
|
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-07-
|
12
|
+
date: 2015-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -207,6 +207,7 @@ files:
|
|
207
207
|
- spec/event_store/binary_string_term_with_null_byte.txt
|
208
208
|
- spec/event_store/client_spec.rb
|
209
209
|
- spec/event_store/config_spec.rb
|
210
|
+
- spec/event_store/event_store_spec.rb
|
210
211
|
- spec/event_store/serialized_binary_event_data.txt
|
211
212
|
- spec/event_store/snapshot_spec.rb
|
212
213
|
- spec/event_store/vertica guy notes.txt
|
@@ -244,6 +245,7 @@ test_files:
|
|
244
245
|
- spec/event_store/binary_string_term_with_null_byte.txt
|
245
246
|
- spec/event_store/client_spec.rb
|
246
247
|
- spec/event_store/config_spec.rb
|
248
|
+
- spec/event_store/event_store_spec.rb
|
247
249
|
- spec/event_store/serialized_binary_event_data.txt
|
248
250
|
- spec/event_store/snapshot_spec.rb
|
249
251
|
- spec/event_store/vertica guy notes.txt
|