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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ad9e3b948091b7a27f35b4be915ba8a784dd43911ad8065767561e62a533aac
4
- data.tar.gz: 164e9e59713eb58ce7301be7462c70e22872ca05f21b479d8c117f54243f9edf
3
+ metadata.gz: b2fe7030703e9d162fe2ffe3007ef76f4fffd8a834dda1e95118f2ce813e735e
4
+ data.tar.gz: 00c25603ad17a4faa1e7b09e23a0e002049dae8931a8e34e789e7a2f3a4d48bb
5
5
  SHA512:
6
- metadata.gz: 5e27ea14bf1bb7bc720026278839a01e96a059ef17750469dfd17c17841e797c0fd3fd10329b8704884a5e5adb69d2a4bd9fc083a16ddfae96b15aafff7e411d
7
- data.tar.gz: ab297fa4dce0255dbe235ce5557b720a9177adae0072968996988b2bfeaf24a5a8b8dc5c9b31eb8aeb5f90e1644da45760b90ce4931459bd4c3d8287ddd1bc71
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;
@@ -10,3 +10,4 @@ BEGIN
10
10
  return hash;
11
11
  END;
12
12
  $$ LANGUAGE plpgsql
13
+ IMMUTABLE;
@@ -10,4 +10,5 @@ BEGIN
10
10
 
11
11
  return stream_version;
12
12
  END;
13
- $$ LANGUAGE plpgsql;
13
+ $$ LANGUAGE plpgsql
14
+ VOLATILE;
@@ -56,4 +56,5 @@ BEGIN
56
56
 
57
57
  return position;
58
58
  END;
59
- $$ LANGUAGE plpgsql;
59
+ $$ LANGUAGE plpgsql
60
+ VOLATILE;
@@ -13,7 +13,7 @@ module MessageStore
13
13
  end
14
14
  end
15
15
 
16
- def self.configure(receiver, attr_name: nil, position: nil, batch_size: nil, condition: nil, session: 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
@@ -15,7 +15,7 @@ module MessageStore
15
15
  end
16
16
 
17
17
  def stream_type_list
18
- @stream_type ||= StreamName.get_type_list(stream_name)
18
+ @stream_type_list ||= StreamName.get_type_list(stream_name)
19
19
  end
20
20
 
21
21
  def category_stream?
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.8.0.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