pg_eventstore 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/pg_eventstore/commands/append.rb +15 -5
- data/lib/pg_eventstore/errors.rb +16 -6
- data/lib/pg_eventstore/tasks/setup.rake +2 -2
- data/lib/pg_eventstore/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f21137e2e5210ac3482ac7dc91d6e7bcb7e34e51e24cbbfa558f891d071fdf4
|
4
|
+
data.tar.gz: 37e42584895549d55d99efd2bc1667916e5ded9c8a0b9539c2081cd2d0a1f323
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2190a042255a6e9b59c6822d586dbc9b142a2189ffc2c3e192fd4bc96862f1c38ceb5307fcf8f4f16d5ab2a0b57852cb46ef3553855f129a08ce289a2293266
|
7
|
+
data.tar.gz: 7b9e343f6fd66e620e8ae19c5d0bf480d393b69763c312786d983a7be90e13a2987ea8b6714268860dcd7d4e851674c755e88dc07c1da18f7bee82ae13480837
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.6.0] - 2024-02-08
|
4
|
+
|
5
|
+
- Add stream info into `PgEventstore::WrongExpectedRevisionError` error details
|
6
|
+
|
7
|
+
## [0.5.3] - 2024-02-07
|
8
|
+
|
9
|
+
- Fix `pg_eventstore:drop` rake task
|
10
|
+
|
3
11
|
## [0.5.2] - 2024-02-06
|
4
12
|
|
5
13
|
- Improve speed of `PgEventstore::Stream#eql?` a bit
|
@@ -18,7 +18,7 @@ module PgEventstore
|
|
18
18
|
queries.transactions.transaction do
|
19
19
|
stream = queries.streams.find_or_create_stream(stream)
|
20
20
|
revision = stream.stream_revision
|
21
|
-
assert_expected_revision!(revision, options[:expected_revision]) if options[:expected_revision]
|
21
|
+
assert_expected_revision!(revision, options[:expected_revision], stream) if options[:expected_revision]
|
22
22
|
events.map.with_index(1) do |event, index|
|
23
23
|
queries.events.insert(stream, event_modifier.call(event, revision + index))
|
24
24
|
end.tap do
|
@@ -31,20 +31,30 @@ module PgEventstore
|
|
31
31
|
|
32
32
|
# @param revision [Integer]
|
33
33
|
# @param expected_revision [Symbol, Integer]
|
34
|
+
# @param stream [PgEventstore::Stream]
|
34
35
|
# @raise [PgEventstore::WrongExpectedRevisionError] in case if revision does not satisfy expected revision
|
35
36
|
# @return [void]
|
36
|
-
def assert_expected_revision!(revision, expected_revision)
|
37
|
+
def assert_expected_revision!(revision, expected_revision, stream)
|
37
38
|
return if expected_revision == :any
|
38
39
|
|
39
40
|
case [revision, expected_revision]
|
40
41
|
in [Integer, Integer]
|
41
|
-
|
42
|
+
unless revision == expected_revision
|
43
|
+
raise WrongExpectedRevisionError.new(
|
44
|
+
revision: revision, expected_revision: expected_revision, stream: stream
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
42
48
|
in [Integer, Symbol]
|
43
49
|
if revision == Stream::INITIAL_STREAM_REVISION && expected_revision == :stream_exists
|
44
|
-
raise WrongExpectedRevisionError.new(
|
50
|
+
raise WrongExpectedRevisionError.new(
|
51
|
+
revision: revision, expected_revision: expected_revision, stream: stream
|
52
|
+
)
|
45
53
|
end
|
46
54
|
if revision > Stream::INITIAL_STREAM_REVISION && expected_revision == :no_stream
|
47
|
-
raise WrongExpectedRevisionError.new(
|
55
|
+
raise WrongExpectedRevisionError.new(
|
56
|
+
revision: revision, expected_revision: expected_revision, stream: stream
|
57
|
+
)
|
48
58
|
end
|
49
59
|
end
|
50
60
|
end
|
data/lib/pg_eventstore/errors.rb
CHANGED
@@ -42,13 +42,15 @@ module PgEventstore
|
|
42
42
|
end
|
43
43
|
|
44
44
|
class WrongExpectedRevisionError < Error
|
45
|
-
attr_reader :revision, :expected_revision
|
45
|
+
attr_reader :stream, :revision, :expected_revision
|
46
46
|
|
47
47
|
# @param revision [Integer]
|
48
48
|
# @param expected_revision [Integer, Symbol]
|
49
|
-
|
49
|
+
# @param stream [PgEventstore::Stream]
|
50
|
+
def initialize(revision:, expected_revision:, stream:)
|
50
51
|
@revision = revision
|
51
52
|
@expected_revision = expected_revision
|
53
|
+
@stream = stream
|
52
54
|
super(user_friendly_message)
|
53
55
|
end
|
54
56
|
|
@@ -65,22 +67,30 @@ module PgEventstore
|
|
65
67
|
|
66
68
|
# @return [String]
|
67
69
|
def expected_stream_exists
|
68
|
-
"Expected stream to exist, but it doesn't."
|
70
|
+
"Expected stream #{stream_descr} to exist, but it doesn't."
|
69
71
|
end
|
70
72
|
|
71
73
|
# @return [String]
|
72
74
|
def expected_no_stream
|
73
|
-
"Expected stream to be absent, but it actually exists."
|
75
|
+
"Expected stream #{stream_descr} to be absent, but it actually exists."
|
74
76
|
end
|
75
77
|
|
76
78
|
# @return [String]
|
77
79
|
def current_no_stream
|
78
|
-
"
|
80
|
+
"#{stream_descr} stream revision #{expected_revision.inspect} is expected, but stream does not exist."
|
79
81
|
end
|
80
82
|
|
81
83
|
# @return [String]
|
82
84
|
def unmatched_stream_revision
|
83
|
-
|
85
|
+
<<~TEXT.strip
|
86
|
+
#{stream_descr} stream revision #{expected_revision.inspect} is expected, but actual stream revision is \
|
87
|
+
#{revision.inspect}.
|
88
|
+
TEXT
|
89
|
+
end
|
90
|
+
|
91
|
+
# @return [String]
|
92
|
+
def stream_descr
|
93
|
+
stream.to_hash.inspect
|
84
94
|
end
|
85
95
|
end
|
86
96
|
|
@@ -59,10 +59,10 @@ namespace :pg_eventstore do
|
|
59
59
|
DROP TABLE IF EXISTS public.streams;
|
60
60
|
DROP TABLE IF EXISTS public.event_types;
|
61
61
|
DROP TABLE IF EXISTS public.migrations;
|
62
|
-
DROP TABLE IF EXISTS public.subscriptions_set;
|
63
|
-
DROP TABLE IF EXISTS public.subscriptions;
|
64
62
|
DROP TABLE IF EXISTS public.subscription_commands;
|
65
63
|
DROP TABLE IF EXISTS public.subscriptions_set_commands;
|
64
|
+
DROP TABLE IF EXISTS public.subscriptions_set;
|
65
|
+
DROP TABLE IF EXISTS public.subscriptions;
|
66
66
|
DROP EXTENSION IF EXISTS "uuid-ossp";
|
67
67
|
DROP EXTENSION IF EXISTS pgcrypto;
|
68
68
|
SQL
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_eventstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Dzyzenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|