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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e85a48e13c5a1778f6415a12a752159d3bac4eb
4
- data.tar.gz: a36146ecdac5d62cb44fd710ae6f3c2f8d9070e1
3
+ metadata.gz: 9df29c67c949b477ed5426265f463804d24d963c
4
+ data.tar.gz: cb3b2c0e6729836e788224acc8e8653e95376e6c
5
5
  SHA512:
6
- metadata.gz: 43e7dcad5a097f20d500763e32ec6786c23fc9b6f15521dd0db18c8f8b2e3f72b04c67f4c3615ad8fe9f530dc589c7bfafce49ef18ea632a78e16e2cf530843f
7
- data.tar.gz: 9c518465879a31e3c25c3a66c372ed54363515d35178c5edf065ff6d4c3a05473ac3ea63433edf2332ac326f1f948adfbe4ad4965169e97fe64790d0222e987f
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 int
4
+ RETURNS bigint
5
5
  AS $$
6
6
  DECLARE
7
- stream_version int;
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 int DEFAULT NULL
7
+ _expected_version bigint DEFAULT NULL
8
8
  )
9
- RETURNS int
9
+ RETURNS bigint
10
10
  AS $$
11
11
  DECLARE
12
12
  message_id uuid;
13
- stream_version int;
14
- position int;
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"."int4_ops" ASC NULLS LAST);
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" int4 NOT NULL,
8
+ "position" bigint NOT NULL,
9
9
  "global_position" bigserial NOT NULL ,
10
10
  "data" jsonb,
11
11
  "metadata" jsonb,
@@ -1,5 +1,6 @@
1
1
  require 'message_store/controls'
2
2
 
3
+ require 'message_store/postgres/controls/position'
3
4
  require 'message_store/postgres/controls/category'
4
5
  require 'message_store/postgres/controls/stream_name'
5
6
  require 'message_store/postgres/controls/message_data'
@@ -0,0 +1,15 @@
1
+ module MessageStore
2
+ module Postgres
3
+ module Controls
4
+ module Position
5
+ def self.example
6
+ 1
7
+ end
8
+
9
+ def self.max
10
+ (2 ** 63) - 1
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,11 +1,3 @@
1
- # module MessageStore
2
- # module Postgres
3
- # module Controls
4
- # StreamName = MessageStore::Controls::StreamName
5
- # end
6
- # end
7
- # end
8
-
9
1
  module MessageStore
10
2
  module Postgres
11
3
  module Controls
@@ -2,15 +2,34 @@ module MessageStore
2
2
  module Postgres
3
3
  class Get
4
4
  class Last
5
- include MessageStore::Get::Last
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(self, session: session)
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.3.0.3
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-08-03 00:00:00.000000000 Z
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