evt-message_store-postgres 0.3.0.3 → 0.4.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/stream-version.sql +2 -2
- data/database/functions/write-message.sql +4 -4
- data/database/indexes/messages-stream-name-position-uniq.sql +1 -1
- data/database/table/messages-table.sql +1 -1
- data/lib/message_store/postgres/controls.rb +1 -0
- data/lib/message_store/postgres/controls/position.rb +15 -0
- data/lib/message_store/postgres/controls/stream_name.rb +0 -8
- data/lib/message_store/postgres/get/last.rb +21 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9df29c67c949b477ed5426265f463804d24d963c
|
4
|
+
data.tar.gz: cb3b2c0e6729836e788224acc8e8653e95376e6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b16e0600a9b4280808c91e8e33b789127095a775eb82129f2bb735241867769c255e00010f87e708d7d6908300b20fe7aa414dae56d3de334610169c8965e388
|
7
|
+
data.tar.gz: c878594db21a9b43a3132ffbda04cbcd47adbfa6fd761fa412df54464eeb8fb3386f2b357e448d0fab07dfb4650932fa9cd9cbea892da2694f335f70d523b80f
|
@@ -1,10 +1,10 @@
|
|
1
1
|
CREATE OR REPLACE FUNCTION stream_version(
|
2
2
|
_stream_name varchar
|
3
3
|
)
|
4
|
-
RETURNS
|
4
|
+
RETURNS bigint
|
5
5
|
AS $$
|
6
6
|
DECLARE
|
7
|
-
stream_version
|
7
|
+
stream_version bigint;
|
8
8
|
BEGIN
|
9
9
|
select max(position) into stream_version from messages where stream_name = _stream_name;
|
10
10
|
|
@@ -4,14 +4,14 @@ CREATE OR REPLACE FUNCTION write_message(
|
|
4
4
|
_type varchar,
|
5
5
|
_data jsonb,
|
6
6
|
_metadata jsonb DEFAULT NULL,
|
7
|
-
_expected_version
|
7
|
+
_expected_version bigint DEFAULT NULL
|
8
8
|
)
|
9
|
-
RETURNS
|
9
|
+
RETURNS bigint
|
10
10
|
AS $$
|
11
11
|
DECLARE
|
12
12
|
message_id uuid;
|
13
|
-
stream_version
|
14
|
-
position
|
13
|
+
stream_version bigint;
|
14
|
+
position bigint;
|
15
15
|
category varchar;
|
16
16
|
BEGIN
|
17
17
|
message_id = uuid(_id);
|
@@ -1 +1 @@
|
|
1
|
-
CREATE UNIQUE INDEX CONCURRENTLY "messages_stream_name_position_uniq_idx" ON "public"."messages" USING btree(stream_name COLLATE "default" "pg_catalog"."text_ops" ASC NULLS LAST, "position" "pg_catalog"."
|
1
|
+
CREATE UNIQUE INDEX CONCURRENTLY "messages_stream_name_position_uniq_idx" ON "public"."messages" USING btree(stream_name COLLATE "default" "pg_catalog"."text_ops" ASC NULLS LAST, "position" "pg_catalog"."int8_ops" ASC NULLS LAST);
|
@@ -5,7 +5,7 @@ CREATE TABLE "public"."messages" (
|
|
5
5
|
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
6
6
|
"stream_name" varchar(255) NOT NULL COLLATE "default",
|
7
7
|
"type" varchar(255) NOT NULL COLLATE "default",
|
8
|
-
"position"
|
8
|
+
"position" bigint NOT NULL,
|
9
9
|
"global_position" bigserial NOT NULL ,
|
10
10
|
"data" jsonb,
|
11
11
|
"metadata" jsonb,
|
@@ -2,15 +2,34 @@ module MessageStore
|
|
2
2
|
module Postgres
|
3
3
|
class Get
|
4
4
|
class Last
|
5
|
-
include
|
5
|
+
include Log::Dependency
|
6
6
|
|
7
7
|
dependency :session, Session
|
8
8
|
|
9
|
+
def self.build(session: nil)
|
10
|
+
new.tap do |instance|
|
11
|
+
instance.configure(session: session)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configure(receiver, attr_name: nil, session: nil)
|
16
|
+
attr_name ||= :get_last
|
17
|
+
instance = build(session: session)
|
18
|
+
receiver.public_send "#{attr_name}=", instance
|
19
|
+
end
|
20
|
+
|
9
21
|
def configure(session: nil)
|
10
|
-
Session.configure
|
22
|
+
Session.configure self, session: session
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.call(stream_name, session: nil)
|
26
|
+
instance = build(session: session)
|
27
|
+
instance.(stream_name)
|
11
28
|
end
|
12
29
|
|
13
30
|
def call(stream_name)
|
31
|
+
logger.trace { "Getting last message data (Stream Name: #{stream_name})" }
|
32
|
+
|
14
33
|
record = get_record(stream_name)
|
15
34
|
|
16
35
|
return nil if record.nil?
|
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.
|
4
|
+
version: 0.4.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: 2017-
|
11
|
+
date: 2017-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-message_store
|
@@ -83,9 +83,9 @@ dependencies:
|
|
83
83
|
description: " "
|
84
84
|
email: opensource@eventide-project.org
|
85
85
|
executables:
|
86
|
+
- evt-pg-create-db
|
86
87
|
- evt-pg-delete-db
|
87
88
|
- evt-pg-list-messages
|
88
|
-
- evt-pg-create-db
|
89
89
|
- evt-pg-recreate-db
|
90
90
|
extensions: []
|
91
91
|
extra_rdoc_files: []
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/message_store/postgres/controls.rb
|
111
111
|
- lib/message_store/postgres/controls/category.rb
|
112
112
|
- lib/message_store/postgres/controls/message_data.rb
|
113
|
+
- lib/message_store/postgres/controls/position.rb
|
113
114
|
- lib/message_store/postgres/controls/put.rb
|
114
115
|
- lib/message_store/postgres/controls/stream_name.rb
|
115
116
|
- lib/message_store/postgres/get.rb
|