evt-message_store-postgres 0.8.0.0 → 0.9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/database/functions/get-messages.sql +63 -0
- data/database/functions/hash-64.sql +1 -0
- data/database/functions/stream-version.sql +2 -1
- data/database/functions/write-message.sql +2 -1
- data/lib/message_store/postgres/get.rb +1 -1
- data/lib/message_store/postgres/get/select_statement.rb +1 -1
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2fe7030703e9d162fe2ffe3007ef76f4fffd8a834dda1e95118f2ce813e735e
|
4
|
+
data.tar.gz: 00c25603ad17a4faa1e7b09e23a0e002049dae8931a8e34e789e7a2f3a4d48bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdd24c589e7c7fae1d55d0d89df6753936a8e2a7da8f2d8af4f4e352c03c4aaefc5ae7bdb2f2c4aeb989035f8fa6009867bb141f1dabe194f7fb3a80ccaae16d
|
7
|
+
data.tar.gz: 31faa413a341b5556c15bc0a895a57ebcc2f22a2368ab81feda00d08ef1158f728a387e7dba7b761e88052ac0cdfed5e1ed7777a5562485c1ba938178d67e478
|
@@ -0,0 +1,63 @@
|
|
1
|
+
CREATE OR REPLACE FUNCTION get_messages(
|
2
|
+
_stream_name varchar,
|
3
|
+
_positon bigint,
|
4
|
+
_batch_size bigint
|
5
|
+
|
6
|
+
|
7
|
+
_type varchar,
|
8
|
+
_data jsonb,
|
9
|
+
_metadata jsonb DEFAULT NULL,
|
10
|
+
_expected_version bigint DEFAULT NULL
|
11
|
+
)
|
12
|
+
RETURNS bigint
|
13
|
+
AS $$
|
14
|
+
DECLARE
|
15
|
+
message_id uuid;
|
16
|
+
stream_version bigint;
|
17
|
+
position bigint;
|
18
|
+
category varchar;
|
19
|
+
stream_name_hash bigint;
|
20
|
+
BEGIN
|
21
|
+
message_id = uuid(_id);
|
22
|
+
|
23
|
+
stream_name_hash = hash_64(_stream_name);
|
24
|
+
PERFORM pg_advisory_xact_lock(stream_name_hash);
|
25
|
+
|
26
|
+
stream_version := stream_version(_stream_name);
|
27
|
+
|
28
|
+
if stream_version is null then
|
29
|
+
stream_version := -1;
|
30
|
+
end if;
|
31
|
+
|
32
|
+
if _expected_version is not null then
|
33
|
+
if _expected_version != stream_version then
|
34
|
+
raise exception 'Wrong expected version: % (Stream: %, Stream Version: %)', _expected_version, _stream_name, stream_version;
|
35
|
+
end if;
|
36
|
+
end if;
|
37
|
+
|
38
|
+
position := stream_version + 1;
|
39
|
+
|
40
|
+
insert into "messages"
|
41
|
+
(
|
42
|
+
"id",
|
43
|
+
"stream_name",
|
44
|
+
"position",
|
45
|
+
"type",
|
46
|
+
"data",
|
47
|
+
"metadata"
|
48
|
+
)
|
49
|
+
values
|
50
|
+
(
|
51
|
+
message_id,
|
52
|
+
_stream_name,
|
53
|
+
position,
|
54
|
+
_type,
|
55
|
+
_data,
|
56
|
+
_metadata
|
57
|
+
)
|
58
|
+
;
|
59
|
+
|
60
|
+
return position;
|
61
|
+
END;
|
62
|
+
$$ LANGUAGE plpgsql
|
63
|
+
VOLATILE;
|
@@ -13,7 +13,7 @@ module MessageStore
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.configure(receiver, attr_name: nil,
|
16
|
+
def self.configure(receiver, attr_name: nil, batch_size: nil, condition: nil, session: nil)
|
17
17
|
attr_name ||= :get
|
18
18
|
instance = build(batch_size: batch_size, condition: condition, session: session)
|
19
19
|
receiver.public_send "#{attr_name}=", instance
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-message_store-postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ntl-actor
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: " "
|
98
112
|
email: opensource@eventide-project.org
|
99
113
|
executables:
|
@@ -107,6 +121,7 @@ files:
|
|
107
121
|
- database/clear-events-table.sh
|
108
122
|
- database/extensions.sql
|
109
123
|
- database/functions/category.sql
|
124
|
+
- database/functions/get-messages.sql
|
110
125
|
- database/functions/hash-64.sql
|
111
126
|
- database/functions/stream-version.sql
|
112
127
|
- database/functions/write-message.sql
|