pg_eventstore 1.13.1 → 1.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +126 -0
- data/CHANGELOG.md +4 -0
- data/exe/pg-eventstore +6 -6
- data/lib/pg_eventstore/abstract_command.rb +1 -1
- data/lib/pg_eventstore/callbacks.rb +7 -2
- data/lib/pg_eventstore/cli/commands/callback_handlers/start_cmd_handlers.rb +1 -0
- data/lib/pg_eventstore/cli/commands/start_subscriptions_command.rb +5 -4
- data/lib/pg_eventstore/cli/parser_options/metadata.rb +4 -4
- data/lib/pg_eventstore/cli/parsers/default_parser.rb +8 -8
- data/lib/pg_eventstore/cli/parsers/subscription_parser.rb +2 -2
- data/lib/pg_eventstore/cli/try_to_delete_subscriptions_set.rb +4 -1
- data/lib/pg_eventstore/cli.rb +4 -4
- data/lib/pg_eventstore/commands/all_stream_read_grouped.rb +2 -2
- data/lib/pg_eventstore/commands/event_modifiers/prepare_link_event.rb +1 -0
- data/lib/pg_eventstore/commands/link_to.rb +4 -5
- data/lib/pg_eventstore/commands/multiple.rb +1 -3
- data/lib/pg_eventstore/commands/regular_stream_read_paginated.rb +1 -1
- data/lib/pg_eventstore/config.rb +1 -1
- data/lib/pg_eventstore/connection.rb +4 -1
- data/lib/pg_eventstore/errors.rb +3 -1
- data/lib/pg_eventstore/extensions/callbacks_extension.rb +2 -0
- data/lib/pg_eventstore/extensions/options_extension.rb +10 -10
- data/lib/pg_eventstore/extensions/using_connection_extension.rb +1 -1
- data/lib/pg_eventstore/pg_connection.rb +7 -5
- data/lib/pg_eventstore/queries/event_queries.rb +11 -10
- data/lib/pg_eventstore/queries/partition_queries.rb +4 -4
- data/lib/pg_eventstore/queries/transaction_queries.rb +5 -9
- data/lib/pg_eventstore/query_builders/events_filtering.rb +13 -13
- data/lib/pg_eventstore/query_builders/partitions_filtering.rb +6 -8
- data/lib/pg_eventstore/rspec/has_option_matcher.rb +12 -13
- data/lib/pg_eventstore/rspec/test_helpers.rb +4 -3
- data/lib/pg_eventstore/sql_builder.rb +9 -13
- data/lib/pg_eventstore/stream.rb +8 -8
- data/lib/pg_eventstore/subscriptions/basic_runner.rb +4 -3
- data/lib/pg_eventstore/subscriptions/commands_handler.rb +1 -1
- data/lib/pg_eventstore/subscriptions/events_processor.rb +1 -1
- data/lib/pg_eventstore/subscriptions/extensions/base_command_extension.rb +10 -8
- data/lib/pg_eventstore/subscriptions/queries/subscription_command_queries.rb +23 -21
- data/lib/pg_eventstore/subscriptions/queries/subscription_queries.rb +11 -8
- data/lib/pg_eventstore/subscriptions/queries/subscriptions_set_command_queries.rb +8 -13
- data/lib/pg_eventstore/subscriptions/queries/subscriptions_set_queries.rb +7 -6
- data/lib/pg_eventstore/subscriptions/runner_recovery_strategies/restore_connection.rb +3 -1
- data/lib/pg_eventstore/subscriptions/runner_recovery_strategies/restore_subscription_runner.rb +1 -0
- data/lib/pg_eventstore/subscriptions/runner_state.rb +3 -1
- data/lib/pg_eventstore/subscriptions/subscription.rb +11 -10
- data/lib/pg_eventstore/subscriptions/subscription_handler_performance.rb +1 -1
- data/lib/pg_eventstore/subscriptions/subscription_runner.rb +1 -1
- data/lib/pg_eventstore/subscriptions/subscriptions_manager.rb +5 -7
- data/lib/pg_eventstore/subscriptions/subscriptions_set.rb +8 -8
- data/lib/pg_eventstore/subscriptions/subscriptions_set_lifecycle.rb +2 -0
- data/lib/pg_eventstore/tasks/setup.rake +7 -6
- data/lib/pg_eventstore/utils.rb +8 -4
- data/lib/pg_eventstore/version.rb +1 -1
- data/lib/pg_eventstore/web/application.rb +22 -15
- data/lib/pg_eventstore/web/paginator/event_types_collection.rb +9 -11
- data/lib/pg_eventstore/web/paginator/events_collection.rb +6 -7
- data/lib/pg_eventstore/web/paginator/helpers.rb +19 -19
- data/lib/pg_eventstore/web/paginator/stream_contexts_collection.rb +9 -9
- data/lib/pg_eventstore/web/paginator/stream_ids_collection.rb +9 -10
- data/lib/pg_eventstore/web/paginator/stream_names_collection.rb +9 -11
- data/lib/pg_eventstore/web/subscriptions/set_collection.rb +1 -1
- data/lib/pg_eventstore/web/subscriptions/subscriptions_to_set_association.rb +2 -0
- data/lib/pg_eventstore/web/subscriptions/with_state/set_collection.rb +1 -1
- data/lib/pg_eventstore.rb +3 -11
- data/pg_eventstore.gemspec +19 -19
- data/sig/pg_eventstore/client.rbs +4 -8
- data/sig/pg_eventstore/subscriptions/subscriptions_manager.rbs +2 -0
- data/sig/pg_eventstore/web/application.rbs +2 -0
- metadata +8 -7
@@ -9,12 +9,11 @@ module PgEventstore
|
|
9
9
|
|
10
10
|
# @return [Array<Hash<String => String>>]
|
11
11
|
def collection
|
12
|
-
@
|
12
|
+
@collection ||=
|
13
13
|
begin
|
14
|
-
sql_builder =
|
15
|
-
|
16
|
-
|
17
|
-
where('stream_name ilike ?', "%#{options[:query]}%")
|
14
|
+
sql_builder = SQLBuilder.new.select('stream_name').from('partitions')
|
15
|
+
sql_builder.where('event_type is null and context = ?', options[:context])
|
16
|
+
sql_builder.where('stream_name ilike ?', "%#{options[:query]}%")
|
18
17
|
sql_builder.where("stream_name #{direction_operator} ?", starting_id) if starting_id
|
19
18
|
sql_builder.limit(per_page).order("stream_name #{order}")
|
20
19
|
connection.with do |conn|
|
@@ -28,12 +27,11 @@ module PgEventstore
|
|
28
27
|
return unless collection.size == per_page
|
29
28
|
|
30
29
|
starting_id = collection.first['stream_name']
|
31
|
-
sql_builder =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
limit(1).offset(per_page).order("stream_name #{order}")
|
30
|
+
sql_builder = SQLBuilder.new.select('stream_name').from('partitions')
|
31
|
+
sql_builder.where("stream_name #{direction_operator} ?", starting_id)
|
32
|
+
sql_builder.where('stream_name ilike ?', "%#{options[:query]}%")
|
33
|
+
sql_builder.where('event_type is null and context = ?', options[:context])
|
34
|
+
sql_builder.limit(1).offset(per_page).order("stream_name #{order}")
|
37
35
|
|
38
36
|
connection.with do |conn|
|
39
37
|
conn.exec_params(*sql_builder.to_exec_params)
|
@@ -16,7 +16,7 @@ module PgEventstore
|
|
16
16
|
|
17
17
|
# @return [Array<String>]
|
18
18
|
def names
|
19
|
-
@
|
19
|
+
@names ||= (subscription_queries.set_collection | subscriptions_set_queries.set_names).sort
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -19,6 +19,7 @@ module PgEventstore
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# @return [Hash{PgEventstore::SubscriptionsSet => Array<PgEventstore::Subscription>}]
|
22
|
+
# rubocop:disable Lint/RedundantWithObject,Lint/UnexpectedBlockArity
|
22
23
|
def association
|
23
24
|
@association ||=
|
24
25
|
begin
|
@@ -31,6 +32,7 @@ module PgEventstore
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
35
|
+
# rubocop:enable Lint/RedundantWithObject,Lint/UnexpectedBlockArity
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
data/lib/pg_eventstore.rb
CHANGED
@@ -31,6 +31,9 @@ module PgEventstore
|
|
31
31
|
attr_reader :mutex
|
32
32
|
private :mutex
|
33
33
|
|
34
|
+
# @return [Logger, nil]
|
35
|
+
attr_accessor :logger
|
36
|
+
|
34
37
|
# Creates a Config if not exists and yields it to the given block.
|
35
38
|
# @param name [Symbol] a name to assign to a config
|
36
39
|
# @return [Object] a result of the given block
|
@@ -107,17 +110,6 @@ module PgEventstore
|
|
107
110
|
Maintenance.new(config(name))
|
108
111
|
end
|
109
112
|
|
110
|
-
# @return [Logger, nil]
|
111
|
-
def logger
|
112
|
-
@logger
|
113
|
-
end
|
114
|
-
|
115
|
-
# @param logger [Logger, nil]
|
116
|
-
# @return [Logger, nil]
|
117
|
-
def logger=(logger)
|
118
|
-
@logger = logger
|
119
|
-
end
|
120
|
-
|
121
113
|
private
|
122
114
|
|
123
115
|
# @return [void]
|
data/pg_eventstore.gemspec
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'lib/pg_eventstore/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = 'pg_eventstore'
|
7
7
|
spec.version = PgEventstore::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
8
|
+
spec.authors = ['Ivan Dzyzenko']
|
9
|
+
spec.email = ['ivan.dzyzenko@gmail.com']
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
15
|
-
spec.required_ruby_version =
|
11
|
+
spec.summary = 'EventStore implementation using PostgreSQL'
|
12
|
+
spec.description = 'EventStore implementation using PostgreSQL'
|
13
|
+
spec.homepage = 'https://github.com/yousty/pg_eventstore'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 3.0'
|
16
16
|
|
17
|
-
spec.metadata[
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
18
|
|
19
|
-
spec.metadata[
|
20
|
-
spec.metadata[
|
21
|
-
spec.metadata[
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = 'https://github.com/yousty/pg_eventstore'
|
21
|
+
spec.metadata['changelog_uri'] = 'https://github.com/yousty/pg_eventstore/blob/main/CHANGELOG.md'
|
22
22
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -28,14 +28,14 @@ Gem::Specification.new do |spec|
|
|
28
28
|
Rakefile benchmark/ .yardopts db/structure.sql config.ru docs/images/
|
29
29
|
]
|
30
30
|
`git ls-files -z`.split("\x0").reject do |f|
|
31
|
-
(File.expand_path(f) == __FILE__) || f.start_with?(*paths_to_exclude) || File.extname(f) ==
|
31
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(*paths_to_exclude) || File.extname(f) == '.map'
|
32
32
|
end
|
33
33
|
end
|
34
|
-
spec.bindir =
|
34
|
+
spec.bindir = 'exe'
|
35
35
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
36
|
-
spec.require_paths = [
|
36
|
+
spec.require_paths = ['lib']
|
37
37
|
|
38
|
-
spec.add_dependency
|
39
|
-
spec.add_dependency
|
40
|
-
spec.add_dependency
|
38
|
+
spec.add_dependency 'connection_pool', '~> 2.4'
|
39
|
+
spec.add_dependency 'pg', '~> 1.5'
|
40
|
+
spec.add_dependency 'sinatra', '>= 3', '< 5'
|
41
41
|
end
|
@@ -28,14 +28,10 @@ module PgEventstore
|
|
28
28
|
|
29
29
|
def read_grouped: (Stream stream, ?options: Hash[untyped, untyped], ?middlewares: ::Array[::Symbol]?) -> ::Array[PgEventstore::Event]
|
30
30
|
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
# _@param_ `middlewares`
|
36
|
-
#
|
37
|
-
# _@return_ — enumerator will yield PgEventstore::Event
|
38
|
-
def read_paginated: (PgEventstore::Stream stream, ?options: ::Hash[untyped, untyped], ?middlewares: ::Array[::Symbol]?) -> ::Enumerator[Array[PgEventstore::Event], void]
|
31
|
+
# Temporary skip RBS checks of this method. It doesn't play well with Enumerator under certain circumstances
|
32
|
+
%a{rbs:test:skip} def read_paginated: (
|
33
|
+
PgEventstore::Stream stream, ?options: ::Hash[untyped, untyped], ?middlewares: ::Array[::Symbol]?
|
34
|
+
) -> ::Enumerator[Array[PgEventstore::Event], void]
|
39
35
|
|
40
36
|
# _@param_ `stream`
|
41
37
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_eventstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.13.
|
4
|
+
version: 1.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Dzyzenko
|
@@ -10,33 +10,33 @@ cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
|
-
name:
|
13
|
+
name: connection_pool
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '
|
18
|
+
version: '2.4'
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: '
|
25
|
+
version: '2.4'
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
27
|
+
name: pg
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '1.5'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '1.5'
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: sinatra
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,6 +65,7 @@ executables:
|
|
65
65
|
extensions: []
|
66
66
|
extra_rdoc_files: []
|
67
67
|
files:
|
68
|
+
- ".rubocop.yml"
|
68
69
|
- CHANGELOG.md
|
69
70
|
- CODE_OF_CONDUCT.md
|
70
71
|
- LICENSE.txt
|