evt-message_store-postgres 0.7.0.2 → 0.8.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: a16ee3f3b8242a06c983a1622539ac2f73a728184e4f2ad11f09838cb2f76aeb
4
- data.tar.gz: 23c759ee3934a4bea9bab61ba824d82ae99c8bf4194403612859209f735b2482
3
+ metadata.gz: 0ad9e3b948091b7a27f35b4be915ba8a784dd43911ad8065767561e62a533aac
4
+ data.tar.gz: 164e9e59713eb58ce7301be7462c70e22872ca05f21b479d8c117f54243f9edf
5
5
  SHA512:
6
- metadata.gz: 624cf0832eff077b61d4b87df2693536503d9d0d26b653c4e216f032d931bdd9f2a838d96a8c954bc8d1f2dab36ea0648c6375f42ad94e4f6f2fd4eb71170b8b
7
- data.tar.gz: dbff7c58fb43b5deb80b25615ed0f93cb71cff5eb7c9d54bfb4aa7dd6f534b07d5fe64c888fe3d9976c72c4016942db0e6387ca235de71a9d5320f23517d5ca9
6
+ metadata.gz: 5e27ea14bf1bb7bc720026278839a01e96a059ef17750469dfd17c17841e797c0fd3fd10329b8704884a5e5adb69d2a4bd9fc083a16ddfae96b15aafff7e411d
7
+ data.tar.gz: ab297fa4dce0255dbe235ce5557b720a9177adae0072968996988b2bfeaf24a5a8b8dc5c9b31eb8aeb5f90e1644da45760b90ce4931459bd4c3d8287ddd1bc71
@@ -0,0 +1,12 @@
1
+ CREATE OR REPLACE FUNCTION hash_64(
2
+ _stream_name varchar
3
+ )
4
+ RETURNS bigint
5
+ AS $$
6
+ DECLARE
7
+ hash bigint;
8
+ BEGIN
9
+ select left('x' || md5(_stream_name), 16)::bit(64)::bigint into hash;
10
+ return hash;
11
+ END;
12
+ $$ LANGUAGE plpgsql
@@ -13,9 +13,13 @@ DECLARE
13
13
  stream_version bigint;
14
14
  position bigint;
15
15
  category varchar;
16
+ stream_name_hash bigint;
16
17
  BEGIN
17
18
  message_id = uuid(_id);
18
19
 
20
+ stream_name_hash = hash_64(_stream_name);
21
+ PERFORM pg_advisory_xact_lock(stream_name_hash);
22
+
19
23
  stream_version := stream_version(_stream_name);
20
24
 
21
25
  if stream_version is null then
data/database/install.sh CHANGED
@@ -70,12 +70,19 @@ function create-table {
70
70
  function create-functions {
71
71
  base=$(script_dir)
72
72
  echo "Creating functions..."
73
+
74
+ echo "hash_64 function"
75
+ psql $database -f $base/functions/hash-64.sql
76
+
73
77
  echo "category function"
74
78
  psql $database -f $base/functions/category.sql
79
+
75
80
  echo "stream_version function"
76
81
  psql $database -f $base/functions/stream-version.sql
82
+
77
83
  echo "write_sql function"
78
84
  psql $database -f $base/functions/write-message.sql
85
+
79
86
  echo
80
87
  }
81
88
 
@@ -0,0 +1 @@
1
+ SELECT hash_64('someStream-123');
@@ -1 +1 @@
1
- SELECT write_message('someStream-123', 'SomeType', '{"someField":"some value"}', '{"someMetadataField":"some metadata value"}', 1);
1
+ SELECT write_message(gen_random_uuid()::varchar, 'testWriteIsolation'::varchar, 'SomeType'::varchar, '{"attribute": "79a59e513f9182d5754abdf9b90e2179"}'::jsonb, '{"metaAttribute": "6b3ae03d713a51a445290f3fc4b5223a"}'::jsonb, 1::bigint);
@@ -1 +1 @@
1
- SELECT write_message('someStream-123', 'SomeType', '{"someField":"some value"}', '{"someMetadataField":"some metadata value"}');
1
+ SELECT write_message(gen_random_uuid()::varchar, 'testWriteIsolation'::varchar, 'SomeType'::varchar, '{"attribute": "79a59e513f9182d5754abdf9b90e2179"}'::jsonb, '{"metaAttribute": "6b3ae03d713a51a445290f3fc4b5223a"}'::jsonb);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-message_store-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.2
4
+ version: 0.8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: scripts
10
10
  cert_chain: []
11
- date: 2018-05-31 00:00:00.000000000 Z
11
+ date: 2018-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-message_store
@@ -107,6 +107,7 @@ files:
107
107
  - database/clear-events-table.sh
108
108
  - database/extensions.sql
109
109
  - database/functions/category.sql
110
+ - database/functions/hash-64.sql
110
111
  - database/functions/stream-version.sql
111
112
  - database/functions/write-message.sql
112
113
  - database/indexes/messages-category-global-position.sql
@@ -115,6 +116,7 @@ files:
115
116
  - database/install.sh
116
117
  - database/print-messages.sh
117
118
  - database/table/messages-table.sql
119
+ - database/test/hash-64.sql
118
120
  - database/test/write-message-expected-version.sql
119
121
  - database/test/write-message.sql
120
122
  - database/uninstall.sh