evt-message_store-postgres 0.1.0.0 → 0.2.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: 1f4b2f2927cc0e063949a067f30ac982f1418e4a
4
- data.tar.gz: 0e9fb2772b23237a597fc14aa1ff0fde0a8567a3
3
+ metadata.gz: 796d8a6dba3a6a145a98ccb15c708b910a4156de
4
+ data.tar.gz: f06453f464d1c9abebfe9187a2e6e93a86c0d9aa
5
5
  SHA512:
6
- metadata.gz: ad29845afd4883df20ea3ed878d6338ff8cf94f892fa9ae8bd59e8d635b745ddfcc4d31ca6255683850d85f5d19fe87f47e2c0dc8f68802c07903f74c8c343cd
7
- data.tar.gz: 3631c15fa6864977c03e3e48d1f395a17c1e201c8319247c70984d3f72694b83c882ae121a9e40074766d799b4d1be197326d49ee204c891099adfd216b05496
6
+ metadata.gz: 6b3ab5078b3db3388afdd8c82d234d90932a01055483947287fd5eeeaeb7dabe8b0a4e98b08d77d3e1765db89834d7c9db5724d0be63b71775eb6265672ec292
7
+ data.tar.gz: 5e4326aa12243973079b0633d08f4e392dcf050524a0e5686cbc19278951669cdec163b94589d2eaf6bb56b31f1bfbeda6b3664c5267641e75da3b3cd0ede145
@@ -7,7 +7,7 @@ echo "Clearing Events Table"
7
7
  echo "= = ="
8
8
  echo
9
9
 
10
- default_name=event_source
10
+ default_name=message_store
11
11
 
12
12
  if [ -z ${DATABASE_USER+x} ]; then
13
13
  echo "(DATABASE_USER is not set)"
@@ -25,7 +25,7 @@ else
25
25
  fi
26
26
  echo "Database name is: $database"
27
27
 
28
- default_table_name=events
28
+ default_table_name=messages
29
29
 
30
30
  if [ -z ${TABLE_NAME+x} ]; then
31
31
  echo "(TABLE_NAME is not set)"
@@ -6,7 +6,7 @@ AS $$
6
6
  DECLARE
7
7
  stream_version int;
8
8
  BEGIN
9
- select max(position) into stream_version from events where stream_name = _stream_name;
9
+ select max(position) into stream_version from messages where stream_name = _stream_name;
10
10
 
11
11
  return stream_version;
12
12
  END;
@@ -1,4 +1,4 @@
1
- CREATE OR REPLACE FUNCTION write_event(
1
+ CREATE OR REPLACE FUNCTION write_message(
2
2
  _id varchar,
3
3
  _stream_name varchar,
4
4
  _type varchar,
@@ -9,12 +9,12 @@ CREATE OR REPLACE FUNCTION write_event(
9
9
  RETURNS int
10
10
  AS $$
11
11
  DECLARE
12
- event_id uuid;
12
+ message_id uuid;
13
13
  stream_version int;
14
14
  position int;
15
15
  category varchar;
16
16
  BEGIN
17
- event_id = uuid(_id);
17
+ message_id = uuid(_id);
18
18
 
19
19
  stream_version := stream_version(_stream_name);
20
20
 
@@ -30,7 +30,7 @@ BEGIN
30
30
 
31
31
  position := stream_version + 1;
32
32
 
33
- insert into "events"
33
+ insert into "messages"
34
34
  (
35
35
  "id",
36
36
  "stream_name",
@@ -41,7 +41,7 @@ BEGIN
41
41
  )
42
42
  values
43
43
  (
44
- event_id,
44
+ message_id,
45
45
  _stream_name,
46
46
  position,
47
47
  _type,
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY "messages_category_global_position_idx" ON "public"."messages" USING btree(category(stream_name) COLLATE "default" "pg_catalog"."text_ops" ASC NULLS LAST, "global_position" "pg_catalog"."int8_ops" ASC NULLS LAST);
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY "messages_category_idx" ON "public"."messages" USING btree(category(stream_name) COLLATE "default" "pg_catalog"."text_ops" ASC NULLS LAST);
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY "messages_id_idx" ON "public"."messages" USING btree(id ASC NULLS LAST);
@@ -0,0 +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);
@@ -0,0 +1 @@
1
+ CREATE INDEX CONCURRENTLY "messages_stream_name_idx" ON "public"."messages" USING btree(stream_name COLLATE "default" "pg_catalog"."text_ops" ASC NULLS LAST);
data/database/install.sh CHANGED
@@ -7,7 +7,7 @@ echo "Installing Database"
7
7
  echo "= = ="
8
8
  echo
9
9
 
10
- default_name=event_source
10
+ default_name=message_store
11
11
 
12
12
  if [ -z ${DATABASE_USER+x} ]; then
13
13
  echo "(DATABASE_USER is not set. Default will be used.)"
@@ -61,9 +61,9 @@ function create-extensions {
61
61
  }
62
62
 
63
63
  function create-table {
64
- echo "Creating events table..."
64
+ echo "Creating messages table..."
65
65
  base=$(script_dir)
66
- psql $database -f $base/table/events-table.sql
66
+ psql $database -f $base/table/messages-table.sql
67
67
  echo
68
68
  }
69
69
 
@@ -75,23 +75,23 @@ function create-functions {
75
75
  echo "stream_version function"
76
76
  psql $database -f $base/functions/stream-version.sql
77
77
  echo "write_sql function"
78
- psql $database -f $base/functions/write-event.sql
78
+ psql $database -f $base/functions/write-message.sql
79
79
  echo
80
80
  }
81
81
 
82
82
  function create-indexes {
83
83
  base=$(script_dir)
84
84
  echo "Creating indexes..."
85
- echo "events_id_idx"
86
- psql $database -f $base/indexes/events-id.sql
87
- echo "events_category_global_position_idx"
88
- psql $database -f $base/indexes/events-category-global-position.sql
89
- echo "events_category_idx"
90
- psql $database -f $base/indexes/events-category.sql
91
- echo "events_stream_name_idx"
92
- psql $database -f $base/indexes/events-stream-name.sql
93
- echo "events_stream_name_position_uniq_idx"
94
- psql $database -f $base/indexes/events-stream-name-position-uniq.sql
85
+ echo "messages_id_idx"
86
+ psql $database -f $base/indexes/messages-id.sql
87
+ echo "messages_category_global_position_idx"
88
+ psql $database -f $base/indexes/messages-category-global-position.sql
89
+ echo "messages_category_idx"
90
+ psql $database -f $base/indexes/messages-category.sql
91
+ echo "messages_stream_name_idx"
92
+ psql $database -f $base/indexes/messages-stream-name.sql
93
+ echo "messages_stream_name_position_uniq_idx"
94
+ psql $database -f $base/indexes/messages-stream-name-position-uniq.sql
95
95
  echo
96
96
  }
97
97
 
@@ -7,7 +7,7 @@ echo "Listing Events"
7
7
  echo "= = ="
8
8
  echo
9
9
 
10
- default_name=event_source
10
+ default_name=message_store
11
11
 
12
12
  if [ -z ${DATABASE_USER+x} ]; then
13
13
  echo "(DATABASE_USER is not set)"
@@ -25,7 +25,7 @@ else
25
25
  fi
26
26
  echo "Database name is: $database"
27
27
 
28
- default_table_name=events
28
+ default_table_name=messages
29
29
 
30
30
  if [ -z ${TABLE_NAME+x} ]; then
31
31
  echo "(TABLE_NAME is not set)"
@@ -1,7 +1,7 @@
1
1
  -- ----------------------------
2
- -- Table structure for events
2
+ -- Table structure for messages
3
3
  -- ----------------------------
4
- CREATE TABLE "public"."events" (
4
+ 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",
@@ -14,6 +14,6 @@ CREATE TABLE "public"."events" (
14
14
  WITH (OIDS=FALSE);
15
15
 
16
16
  -- ----------------------------
17
- -- Primary key structure for table events
17
+ -- Primary key structure for table messages
18
18
  -- ----------------------------
19
- ALTER TABLE "public"."events" ADD PRIMARY KEY ("global_position") NOT DEFERRABLE INITIALLY IMMEDIATE;
19
+ ALTER TABLE "public"."messages" ADD PRIMARY KEY ("global_position") NOT DEFERRABLE INITIALLY IMMEDIATE;
@@ -0,0 +1 @@
1
+ SELECT write_message('someStream-123', 'SomeType', '{"someField":"some value"}', '{"someMetadataField":"some metadata value"}', 1);
@@ -0,0 +1 @@
1
+ SELECT write_message('someStream-123', 'SomeType', '{"someField":"some value"}', '{"someMetadataField":"some metadata value"}');
@@ -7,7 +7,7 @@ echo "Uninstalling Database"
7
7
  echo "= = ="
8
8
  echo
9
9
 
10
- default_name=event_source
10
+ default_name=message_store
11
11
 
12
12
  if [ -z ${DATABASE_USER+x} ]; then
13
13
  echo "(DATABASE_USER is not set. Default will be used.)"
@@ -25,7 +25,7 @@ module MessageStore
25
25
  metadata::varchar,
26
26
  time::timestamp
27
27
  FROM
28
- events
28
+ messages
29
29
  WHERE
30
30
  stream_name = '#{stream_name}'
31
31
  ORDER BY
@@ -40,7 +40,7 @@ module MessageStore
40
40
  metadata::varchar,
41
41
  time::timestamp
42
42
  FROM
43
- events
43
+ messages
44
44
  WHERE
45
45
  #{where_clause_field} = '#{stream_name}' AND
46
46
  #{position_field} >= #{position}
@@ -88,7 +88,7 @@ module MessageStore
88
88
  end
89
89
 
90
90
  def self.statement
91
- @statement ||= "SELECT write_event($1::varchar, $2::varchar, $3::varchar, $4::jsonb, $5::jsonb, $6::int);"
91
+ @statement ||= "SELECT write_message($1::varchar, $2::varchar, $3::varchar, $4::jsonb, $5::jsonb, $6::int);"
92
92
  end
93
93
 
94
94
  def serialized_data(data)
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.1.0.0
4
+ version: 0.2.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-05-26 00:00:00.000000000 Z
11
+ date: 2017-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-message_store
@@ -94,17 +94,17 @@ files:
94
94
  - database/extensions.sql
95
95
  - database/functions/category.sql
96
96
  - database/functions/stream-version.sql
97
- - database/functions/write-event.sql
98
- - database/indexes/events-category-global-position.sql
99
- - database/indexes/events-category.sql
100
- - database/indexes/events-id.sql
101
- - database/indexes/events-stream-name-position-uniq.sql
102
- - database/indexes/events-stream-name.sql
97
+ - database/functions/write-message.sql
98
+ - database/indexes/messages-category-global-position.sql
99
+ - database/indexes/messages-category.sql
100
+ - database/indexes/messages-id.sql
101
+ - database/indexes/messages-stream-name-position-uniq.sql
102
+ - database/indexes/messages-stream-name.sql
103
103
  - database/install.sh
104
104
  - database/list-events.sh
105
- - database/table/events-table.sql
106
- - database/test/write-event-expected-version.sql
107
- - database/test/write-event.sql
105
+ - database/table/messages-table.sql
106
+ - database/test/write-message-expected-version.sql
107
+ - database/test/write-message.sql
108
108
  - database/uninstall.sh
109
109
  - lib/message_store/postgres.rb
110
110
  - lib/message_store/postgres/controls.rb
@@ -128,7 +128,6 @@ files:
128
128
  - scripts/evt-pg-delete-db
129
129
  - scripts/evt-pg-list-events
130
130
  - scripts/evt-pg-recreate-db
131
- - scripts/scripts_init.rb
132
131
  homepage: https://github.com/eventide-project/message-store-postgres
133
132
  licenses:
134
133
  - MIT
@@ -152,5 +151,5 @@ rubyforge_project:
152
151
  rubygems_version: 2.6.11
153
152
  signing_key:
154
153
  specification_version: 4
155
- summary: Event source client for PostgreSQL
154
+ summary: Message store implementation for PostgreSQL
156
155
  test_files: []
@@ -1 +0,0 @@
1
- CREATE INDEX CONCURRENTLY "events_category_global_position_idx" ON "public"."events" USING btree(category(stream_name) COLLATE "default" "pg_catalog"."text_ops" ASC NULLS LAST, "global_position" "pg_catalog"."int8_ops" ASC NULLS LAST);
@@ -1 +0,0 @@
1
- CREATE INDEX CONCURRENTLY "events_category_idx" ON "public"."events" USING btree(category(stream_name) COLLATE "default" "pg_catalog"."text_ops" ASC NULLS LAST);
@@ -1 +0,0 @@
1
- CREATE INDEX CONCURRENTLY "events_id_idx" ON "public"."events" USING btree(id ASC NULLS LAST);
@@ -1 +0,0 @@
1
- CREATE UNIQUE INDEX CONCURRENTLY "events_stream_name_position_uniq_idx" ON "public"."events" USING btree(stream_name COLLATE "default" "pg_catalog"."text_ops" ASC NULLS LAST, "position" "pg_catalog"."int4_ops" ASC NULLS LAST);
@@ -1 +0,0 @@
1
- CREATE INDEX CONCURRENTLY "events_stream_name_idx" ON "public"."events" USING btree(stream_name COLLATE "default" "pg_catalog"."text_ops" ASC NULLS LAST);
@@ -1 +0,0 @@
1
- SELECT write_event('someStream-123', 'SomeType', '{"someField":"some value"}', '{"someMetadataField":"some metadata value"}', 1);
@@ -1 +0,0 @@
1
- SELECT write_event('someStream-123', 'SomeType', '{"someField":"some value"}', '{"someMetadataField":"some metadata value"}');
@@ -1,12 +0,0 @@
1
- ENV['CONSOLE_DEVICE'] ||= 'stdout'
2
- ENV['LOG_LEVEL'] ||= '_min'
3
-
4
- puts RUBY_DESCRIPTION
5
-
6
- init_file = File.expand_path('../init.rb', __dir__)
7
- if File.exist?(init_file)
8
- require_relative '../init'
9
- end
10
-
11
- require 'event_source/postgres'
12
- require 'event_source/postgres/database'