pg_eventstore 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/README.md +4 -0
  4. data/docs/subscriptions.md +14 -56
  5. data/exe/pg-eventstore +16 -0
  6. data/lib/pg_eventstore/callbacks.rb +16 -0
  7. data/lib/pg_eventstore/cli/commands/base_command.rb +45 -0
  8. data/lib/pg_eventstore/cli/commands/callback_handlers/start_cmd_handlers.rb +38 -0
  9. data/lib/pg_eventstore/cli/commands/help_command.rb +22 -0
  10. data/lib/pg_eventstore/cli/commands/start_subscriptions_command.rb +96 -0
  11. data/lib/pg_eventstore/cli/commands/stop_subscriptions_command.rb +22 -0
  12. data/lib/pg_eventstore/cli/commands.rb +6 -0
  13. data/lib/pg_eventstore/cli/exit_codes.rb +12 -0
  14. data/lib/pg_eventstore/cli/parser_options/base_options.rb +46 -0
  15. data/lib/pg_eventstore/cli/parser_options/default_options.rb +10 -0
  16. data/lib/pg_eventstore/cli/parser_options/metadata.rb +34 -0
  17. data/lib/pg_eventstore/cli/parser_options/subscription_options.rb +31 -0
  18. data/lib/pg_eventstore/cli/parser_options.rb +6 -0
  19. data/lib/pg_eventstore/cli/parsers/base_parser.rb +33 -0
  20. data/lib/pg_eventstore/cli/parsers/default_parser.rb +24 -0
  21. data/lib/pg_eventstore/cli/parsers/subscription_parser.rb +24 -0
  22. data/lib/pg_eventstore/cli/parsers.rb +5 -0
  23. data/lib/pg_eventstore/cli/try_to_delete_subscriptions_set.rb +75 -0
  24. data/lib/pg_eventstore/cli/try_unlock_subscriptions_set.rb +16 -0
  25. data/lib/pg_eventstore/cli/wait_for_subscriptions_set_shutdown.rb +67 -0
  26. data/lib/pg_eventstore/cli.rb +42 -0
  27. data/lib/pg_eventstore/extensions/options_extension.rb +53 -8
  28. data/lib/pg_eventstore/rspec/has_option_matcher.rb +38 -13
  29. data/lib/pg_eventstore/subscriptions/command_handlers/subscription_feeder_commands.rb +13 -1
  30. data/lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb +1 -1
  31. data/lib/pg_eventstore/subscriptions/queries/subscription_command_queries.rb +1 -1
  32. data/lib/pg_eventstore/subscriptions/queries/subscriptions_set_command_queries.rb +3 -1
  33. data/lib/pg_eventstore/subscriptions/subscription_feeder.rb +10 -50
  34. data/lib/pg_eventstore/subscriptions/subscription_feeder_commands/ping.rb +22 -0
  35. data/lib/pg_eventstore/subscriptions/subscription_feeder_commands.rb +1 -0
  36. data/lib/pg_eventstore/subscriptions/subscriptions_lifecycle.rb +7 -2
  37. data/lib/pg_eventstore/subscriptions/subscriptions_manager.rb +44 -10
  38. data/lib/pg_eventstore/subscriptions/subscriptions_set_lifecycle.rb +1 -1
  39. data/lib/pg_eventstore/utils.rb +32 -0
  40. data/lib/pg_eventstore/version.rb +1 -1
  41. data/lib/pg_eventstore/web/views/home/partials/event_filter.erb +1 -1
  42. data/lib/pg_eventstore/web/views/home/partials/events.erb +5 -5
  43. data/lib/pg_eventstore/web/views/home/partials/stream_filter.erb +3 -3
  44. data/lib/pg_eventstore/web/views/layouts/application.erb +3 -3
  45. data/lib/pg_eventstore/web/views/subscriptions/index.erb +6 -6
  46. data/lib/pg_eventstore.rb +5 -2
  47. data/sig/pg_eventstore/callbacks.rbs +4 -0
  48. data/sig/pg_eventstore/cli/commands/base_command.rbs +13 -0
  49. data/sig/pg_eventstore/cli/commands/callback_handlers/start_cmd_handlers.rbs +14 -0
  50. data/sig/pg_eventstore/cli/commands/help_command.rbs +13 -0
  51. data/sig/pg_eventstore/cli/commands/start_subscriptions_command.rbs +28 -0
  52. data/sig/pg_eventstore/cli/commands/stop_subscriptions_command.rbs +11 -0
  53. data/sig/pg_eventstore/cli/exit_codes.rbs +8 -0
  54. data/sig/pg_eventstore/cli/parser_options/base_options.rbs +15 -0
  55. data/sig/pg_eventstore/cli/parser_options/default_options.rbs +8 -0
  56. data/sig/pg_eventstore/cli/parser_options/metadata.rbs +11 -0
  57. data/sig/pg_eventstore/cli/parser_options/subscription_options.rbs +9 -0
  58. data/sig/pg_eventstore/cli/parsers/base_parser.rbs +18 -0
  59. data/sig/pg_eventstore/cli/parsers/default_parser.rbs +9 -0
  60. data/sig/pg_eventstore/cli/parsers/subscription_parser.rbs +9 -0
  61. data/sig/pg_eventstore/cli/try_to_delete_subscriptions_set.rbs +24 -0
  62. data/sig/pg_eventstore/cli/try_unlock_subscriptions_set.rbs +7 -0
  63. data/sig/pg_eventstore/cli/wait_for_subscriptions_set_shutdown.rbs +26 -0
  64. data/sig/pg_eventstore/cli.rbs +10 -0
  65. data/sig/pg_eventstore/extensions/options_extension.rbs +18 -1
  66. data/sig/pg_eventstore/subscriptions/command_handlers/subscription_feeder_commands.rbs +8 -0
  67. data/sig/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rbs +7 -1
  68. data/sig/pg_eventstore/subscriptions/queries/subscription_command_queries.rbs +1 -1
  69. data/sig/pg_eventstore/subscriptions/queries/subscriptions_set_command_queries.rbs +1 -1
  70. data/sig/pg_eventstore/subscriptions/subscription_feeder.rbs +10 -11
  71. data/sig/pg_eventstore/subscriptions/subscription_feeder_commands/ping.rbs +11 -0
  72. data/sig/pg_eventstore/subscriptions/subscriptions_lifecycle.rbs +1 -1
  73. data/sig/pg_eventstore/subscriptions/subscriptions_manager.rbs +13 -1
  74. data/sig/pg_eventstore/utils.rbs +2 -0
  75. data/sig/pg_eventstore.rbs +2 -8
  76. metadata +44 -3
@@ -36,20 +36,32 @@ module PgEventstore
36
36
  attr_reader :config
37
37
  private :config
38
38
 
39
- def_delegators :@subscription_feeder, :stop, :force_lock!
39
+ def_delegators :@subscription_feeder, :stop, :running?
40
+ def_delegators :@subscriptions_lifecycle, :force_lock!
40
41
 
41
42
  # @param config [PgEventstore::Config]
42
43
  # @param set_name [String]
43
44
  # @param max_retries [Integer, nil] max number of retries of failed SubscriptionsSet
44
45
  # @param retries_interval [Integer, nil] a delay between retries of failed SubscriptionsSet
45
- def initialize(config:, set_name:, max_retries: nil, retries_interval: nil)
46
+ # @param force_lock [Boolean] whether to force-lock subscriptions
47
+ def initialize(config:, set_name:, max_retries: nil, retries_interval: nil, force_lock: false)
46
48
  @config = config
47
49
  @set_name = set_name
50
+ @subscriptions_set_lifecycle = SubscriptionsSetLifecycle.new(
51
+ config_name,
52
+ {
53
+ name: set_name,
54
+ max_restarts_number: max_retries || config.subscriptions_set_max_retries,
55
+ time_between_restarts: retries_interval || config.subscriptions_set_retries_interval
56
+ }
57
+ )
58
+ @subscriptions_lifecycle = SubscriptionsLifecycle.new(
59
+ config_name, @subscriptions_set_lifecycle, force_lock: force_lock
60
+ )
48
61
  @subscription_feeder = SubscriptionFeeder.new(
49
- config_name: config.name,
50
- set_name: set_name,
51
- max_retries: max_retries || config.subscriptions_set_max_retries,
52
- retries_interval: retries_interval || config.subscriptions_set_retries_interval
62
+ config_name: config_name,
63
+ subscriptions_set_lifecycle: @subscriptions_set_lifecycle,
64
+ subscriptions_lifecycle: @subscriptions_lifecycle
53
65
  )
54
66
  end
55
67
 
@@ -97,30 +109,52 @@ module PgEventstore
97
109
  failed_subscription_notifier: failed_subscription_notifier
98
110
  )
99
111
 
100
- @subscription_feeder.add(runner)
112
+ @subscriptions_lifecycle.runners.push(runner)
101
113
  true
102
114
  end
103
115
 
104
116
  # @return [Array<PgEventstore::Subscription>]
105
117
  def subscriptions
106
- @subscription_feeder.read_only_subscriptions
118
+ @subscriptions_lifecycle.subscriptions.map(&:dup)
107
119
  end
108
120
 
109
121
  # @return [PgEventstore::SubscriptionsSet, nil]
110
122
  def subscriptions_set
111
- @subscription_feeder.read_only_subscriptions_set
123
+ @subscriptions_set_lifecycle.subscriptions_set&.dup
124
+ end
125
+
126
+ # @return [PgEventstore::BasicRunner]
127
+ # @raise [PgEventstore::SubscriptionAlreadyLockedError]
128
+ def start!
129
+ run_cli_callbacks do
130
+ @subscription_feeder.start
131
+ end
112
132
  end
113
133
 
114
134
  # @return [PgEventstore::BasicRunner, nil]
115
135
  def start
116
- @subscription_feeder.start
136
+ start!
117
137
  rescue PgEventstore::SubscriptionAlreadyLockedError => e
118
138
  PgEventstore.logger&.warn(e.message)
119
139
  nil
120
140
  end
121
141
 
142
+ # @return [Symbol]
143
+ def config_name
144
+ @config.name
145
+ end
146
+
122
147
  private
123
148
 
149
+ # @return [Object] the result of the passed block
150
+ def run_cli_callbacks
151
+ return yield unless defined?(::PgEventstore::CLI)
152
+
153
+ PgEventstore::CLI.callbacks.run_callbacks(:start_manager, self) do
154
+ yield
155
+ end
156
+ end
157
+
124
158
  # @param middlewares [Array<Symbol>, nil]
125
159
  # @param handler [#call]
126
160
  # @return [Proc]
@@ -27,7 +27,7 @@ module PgEventstore
27
27
 
28
28
  # @return [PgEventstore::SubscriptionsSet]
29
29
  def persisted_subscriptions_set
30
- @subscriptions_set ||= SubscriptionsSet.using_connection(@config_name).create(**@subscriptions_set_attrs)
30
+ @subscriptions_set ||= SubscriptionsSet.using_connection(@config_name).create(@subscriptions_set_attrs)
31
31
  end
32
32
 
33
33
  # @return [void]
@@ -69,6 +69,38 @@ module PgEventstore
69
69
  def original_global_position(raw_event)
70
70
  raw_event['link'] ? raw_event['link']['global_position'] : raw_event['global_position']
71
71
  end
72
+
73
+ # @param message [String]
74
+ # @return [void]
75
+ def deprecation_warning(message)
76
+ PgEventstore.logger&.warn("\e[31m[DEPRECATED]: #{message}\e[0m")
77
+ end
78
+
79
+ # @param file_path [String]
80
+ # @param content [String]
81
+ # @return [void]
82
+ def write_to_file(file_path, content)
83
+ file = File.open(file_path, "w")
84
+ file.write(content)
85
+ file.close
86
+ end
87
+
88
+ # @param file_path [String]
89
+ # @return [void]
90
+ def remove_file(file_path)
91
+ File.delete(file_path)
92
+ rescue Errno::ENOENT
93
+ end
94
+
95
+ # @param file_path [String]
96
+ # @return [String, nil]
97
+ def read_pid(file_path)
98
+ file = File.open(file_path, "r")
99
+ file.readline.strip.tap do
100
+ file.close
101
+ end
102
+ rescue Errno::ENOENT
103
+ end
72
104
  end
73
105
  end
74
106
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module PgEventstore
4
4
  # @return [String]
5
- VERSION = "1.5.0"
5
+ VERSION = "1.6.0"
6
6
  end
@@ -3,7 +3,7 @@
3
3
  <select name="filter[events][]" class="form-control mb-2" data-placeholder="Event type" data-url="<%= url('/event_types_filtering') %>">
4
4
  <option></option>
5
5
  <% if event_type %>
6
- <option value="<%= event_type %>" selected><%= event_type %></option>
6
+ <option value="<%= h event_type %>" selected><%= h event_type %></option>
7
7
  <% end %>
8
8
  </select>
9
9
  </div>
@@ -2,11 +2,11 @@
2
2
  <tr>
3
3
  <td><%= event.global_position %></td>
4
4
  <td><%= event.stream_revision %></td>
5
- <td><%= event.stream.context %></td>
6
- <td><%= event.stream.stream_name %></td>
5
+ <td><%= h event.stream.context %></td>
6
+ <td><%= h event.stream.stream_name %></td>
7
7
  <td><a href="<%= stream_path(event) %>"><%= event.stream.stream_id %></a></td>
8
8
  <td>
9
- <%= event.type %>
9
+ <%= h event.type %>
10
10
  <% if event.link %>
11
11
  <i class="fa fa-link"></i>
12
12
  <% end %>
@@ -19,9 +19,9 @@
19
19
  <tr class="event-payload d-none">
20
20
  <td colspan="8">
21
21
  <strong>Data:</strong>
22
- <pre><%= JSON.pretty_generate(event.data) %></pre>
22
+ <pre><%= h JSON.pretty_generate(event.data) %></pre>
23
23
  <strong>Metadata:</strong>
24
- <pre><%= JSON.pretty_generate(event.metadata) %></pre>
24
+ <pre><%= h JSON.pretty_generate(event.metadata) %></pre>
25
25
  </td>
26
26
  </tr>
27
27
  <% end %>
@@ -3,7 +3,7 @@
3
3
  <select name="filter[streams][][context]" class="form-control mb-2" data-placeholder="Context" data-url="<%= url('/stream_contexts_filtering') %>">
4
4
  <option></option>
5
5
  <% if stream[:context] %>
6
- <option value="<%= stream[:context] %>" selected><%= stream[:context] %></option>
6
+ <option value="<%= h stream[:context] %>" selected><%= h stream[:context] %></option>
7
7
  <% end %>
8
8
  </select>
9
9
  </div>
@@ -11,7 +11,7 @@
11
11
  <select name="filter[streams][][stream_name]" class="form-control mb-2" data-placeholder="Stream name" data-url="<%= url('/stream_names_filtering') %>">
12
12
  <option></option>
13
13
  <% if stream[:stream_name] %>
14
- <option value="<%= stream[:stream_name] %>" selected><%= stream[:stream_name] %></option>
14
+ <option value="<%= h stream[:stream_name] %>" selected><%= h stream[:stream_name] %></option>
15
15
  <% end %>
16
16
  </select>
17
17
  </div>
@@ -19,7 +19,7 @@
19
19
  <select name="filter[streams][][stream_id]" class="form-control mb-2" data-placeholder="Stream ID" data-url="<%= url('/stream_ids_filtering') %>">
20
20
  <option></option>
21
21
  <% if stream[:stream_id] %>
22
- <option value="<%= stream[:stream_id] %>" selected><%= stream[:stream_id] %></option>
22
+ <option value="<%= h stream[:stream_id] %>" selected><%= h stream[:stream_id] %></option>
23
23
  <% end %>
24
24
  </select>
25
25
  </div>
@@ -82,13 +82,13 @@
82
82
  <ul class="navbar-right" style="height: 29px;">
83
83
  <li class="nav-item dropdown open" style="padding-left: 15px;">
84
84
  <a href="javascript: void(0);" class="user-profile dropdown-toggle" aria-haspopup="true" id="navbarDropdown" data-toggle="dropdown" aria-expanded="false">
85
- <strong>Current config:</strong> <%= current_config.inspect %>
85
+ <strong>Current config:</strong> <%= h current_config.inspect %>
86
86
  </a>
87
87
  <div class="dropdown-menu dropdown-usermenu pull-right" aria-labelledby="navbarDropdown">
88
88
  <% PgEventstore.available_configs.each do |config| %>
89
89
  <form action="<%= url('/change_config') %>" method="POST">
90
- <input type="hidden" name="config" value="<%= config %>">
91
- <button type="submit" class="dropdown-item"><%= config.inspect %></button>
90
+ <input type="hidden" name="config" value="<%= h config %>">
91
+ <button type="submit" class="dropdown-item"><%= h config.inspect %></button>
92
92
  </form>
93
93
  <% end %>
94
94
  </div>
@@ -24,7 +24,7 @@
24
24
  <% @set_collection.names.each do |set_name| %>
25
25
  <li class="nav-item">
26
26
  <a class="nav-link <%= "active bg-dark text-white" if @current_set == set_name %>" href="<%= subscriptions_state ? subscriptions_state_url(state: subscriptions_state, set_name: set_name) : subscriptions_url(set_name: set_name) %>">
27
- <%= set_name %>
27
+ <%= h set_name %>
28
28
  </a>
29
29
  </li>
30
30
  <% end %>
@@ -86,7 +86,7 @@
86
86
  </a>
87
87
  <% end %>
88
88
  <% if PgEventstore::RunnerState::STATES.values_at(:running, :dead).include?(subscriptions_set.state) %>
89
- <a class="btn btn-warning" data-confirm="You are about to stop SubscriptionsSet#<%= subscriptions_set.id %>. This will also delete it and will result in stopping all related Subscriptions. Continue?" data-confirm-title="Stop SubscriptionsSet" data-method="post" href="<%= subscriptions_set_cmd_url(subscriptions_set.id, subscriptions_set_cmd('Stop')) %>" data-toggle="tooltip" title="This action will delete Subscriptions Set and release all related Subscriptions.">
89
+ <a class="btn btn-warning" data-confirm="You are about to stop SubscriptionsSet#<%= subscriptions_set.id %>. This will also delete it and will result in stopping all related Subscriptions. If you used pg_eventstore CLI to start subscriptions - the related process will also be stopped. Continue?" data-confirm-title="Stop SubscriptionsSet" data-method="post" href="<%= subscriptions_set_cmd_url(subscriptions_set.id, subscriptions_set_cmd('Stop')) %>" data-toggle="tooltip" title="This action will delete Subscriptions Set and release all related Subscriptions.">
90
90
  Stop
91
91
  </a>
92
92
  <% end %>
@@ -98,7 +98,7 @@
98
98
  <% if subscriptions_set.last_error %>
99
99
  <tr class="collapse" id="last-set-error-<%= subscriptions_set.id %>">
100
100
  <td colspan="9">
101
- <pre><%= JSON.pretty_generate(subscriptions_set.last_error) %></pre>
101
+ <pre><%= h JSON.pretty_generate(subscriptions_set.last_error) %></pre>
102
102
  </td>
103
103
  </tr>
104
104
  <% end %>
@@ -151,7 +151,7 @@
151
151
  <% subscriptions.each do |subscription| %>
152
152
  <tr>
153
153
  <td><%= subscription.id %></td>
154
- <td><%= subscription.name %></td>
154
+ <td><%= h subscription.name %></td>
155
155
  <td><%= subscription.total_processed_events %></td>
156
156
  <td>
157
157
  <a data-toggle="collapse" href="#options-<%= subscription.id %>" aria-controls="options-<%= subscription.id %>" role="button" aria-expanded="false" class="d-inline-block text-nowrap">
@@ -209,13 +209,13 @@
209
209
  </tr>
210
210
  <tr class="collapse" id="options-<%= subscription.id %>">
211
211
  <td colspan="16">
212
- <pre><%= JSON.pretty_generate(subscription.options) %></pre>
212
+ <pre><%= h JSON.pretty_generate(subscription.options) %></pre>
213
213
  </td>
214
214
  </tr>
215
215
  <% if subscription.last_error %>
216
216
  <tr class="collapse" id="last-error-<%= subscription.id %>">
217
217
  <td colspan="16">
218
- <pre><%= JSON.pretty_generate(subscription.last_error) %></pre>
218
+ <pre><%= h JSON.pretty_generate(subscription.last_error) %></pre>
219
219
  </td>
220
220
  </tr>
221
221
  <% end %>
data/lib/pg_eventstore.rb CHANGED
@@ -74,13 +74,16 @@ module PgEventstore
74
74
  # @param subscription_set [String]
75
75
  # @param max_retries [Integer, nil] max number of retries of failed SubscriptionsSet
76
76
  # @param retries_interval [Integer, nil] a delay between retries of failed SubscriptionsSet
77
+ # @param force_lock [Boolean] whether to force-lock subscriptions
77
78
  # @return [PgEventstore::SubscriptionsManager]
78
- def subscriptions_manager(config_name = :default, subscription_set:, max_retries: nil, retries_interval: nil)
79
+ def subscriptions_manager(config_name = :default, subscription_set:, max_retries: nil, retries_interval: nil,
80
+ force_lock: false)
79
81
  SubscriptionsManager.new(
80
82
  config: config(config_name),
81
83
  set_name: subscription_set,
82
84
  max_retries: max_retries,
83
- retries_interval: retries_interval
85
+ retries_interval: retries_interval,
86
+ force_lock: force_lock
84
87
  )
85
88
  end
86
89
 
@@ -2,6 +2,8 @@ module PgEventstore
2
2
  class Callbacks
3
3
  def initialize: () -> void
4
4
 
5
+ def clear: -> void
6
+
5
7
  # _@param_ `action` — an object, that represents your action. In most cases you want to use a symbol there
6
8
  #
7
9
  # _@param_ `filter` — callback filter. Supported values are :before, :after and :around
@@ -9,6 +11,8 @@ module PgEventstore
9
11
  # _@param_ `callback`
10
12
  def define_callback: (untyped action, Symbol filter, _Callback callback) -> void
11
13
 
14
+ def remove_callback: (untyped action, Symbol filter, _Callback callback) -> void
15
+
12
16
  # _@param_ `action` — an action to run
13
17
  def run_callbacks: (untyped action, *untyped args, **untyped kwargs) ?{ () -> untyped } -> untyped
14
18
 
@@ -0,0 +1,13 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module Commands
4
+ class BaseCommand
5
+ attr_reader options: PgEventstore::CLI::ParserOptions::BaseOptions
6
+
7
+ %a{rbs:test:skip} def initialize: (PgEventstore::CLI::ParserOptions::BaseOptions options) -> untyped
8
+
9
+ def call: -> Integer
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module Commands
4
+ module CallbackHandlers
5
+ class StartCmdHandlers
6
+ def self.handle_start_up: (Proc action, PgEventstore::SubscriptionsManager manager) -> void
7
+
8
+ def self.register_managers: (Set[PgEventstore::SubscriptionsManager] subscription_managers,
9
+ PgEventstore::SubscriptionsManager manager) -> void
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module Commands
4
+ class HelpCommand
5
+ attr_reader options: PgEventstore::CLI::ParserOptions::BaseOptions
6
+
7
+ def initialize: (PgEventstore::CLI::ParserOptions::BaseOptions options) -> void
8
+
9
+ %a{rbs:test:skip} def call: -> Integer
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module Commands
4
+ class StartSubscriptionsCommand
5
+ KEEP_ALIVE_INTERVAL: Integer
6
+
7
+ @running: bool
8
+ @subscription_managers: Set[PgEventstore::SubscriptionsManager]
9
+
10
+ def initialize: (PgEventstore::CLI::ParserOptions::BaseOptions options) -> void
11
+
12
+ %a{rbs:test:skip} def call: -> Integer
13
+
14
+ private
15
+
16
+ def attach_callbacks: -> void
17
+
18
+ def keep_process_alive: -> void
19
+
20
+ def persist_pid: -> void
21
+
22
+ def running_subscriptions?: -> bool
23
+
24
+ def setup_killsig: -> void
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module Commands
4
+ class StopSubscriptionsCommand
5
+ %a{rbs:test:skip} def call: -> Integer
6
+
7
+ def initialize: (PgEventstore::CLI::ParserOptions::BaseOptions options) -> void
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module ExitCodes
4
+ ERROR: Integer
5
+ SUCCESS: Integer
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module ParserOptions
4
+ class BaseOptions
5
+ include PgEventstore::Extensions::OptionsExtension
6
+
7
+ def attach_parser_handlers: (OptionParser parser) -> void
8
+
9
+ def option: (Symbol option) -> PgEventstore::Extensions::OptionsExtension::Option
10
+
11
+ def to_parser_opts: (Symbol option) -> Array[String]
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module ParserOptions
4
+ class DefaultOptions
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module ParserOptions
4
+ class Metadata
5
+ include PgEventstore::Extensions::OptionsExtension
6
+
7
+ def to_parser_opts: -> Array[String]
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module ParserOptions
4
+ class SubscriptionOptions
5
+ def attach_parser_handlers: (OptionParser parser) -> void
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module Parsers
4
+ class BaseParser
5
+ @parser: OptionParser
6
+
7
+ def self.banner: -> String
8
+
9
+ attr_reader args: Array[String]
10
+ attr_reader options: PgEventstore::CLI::ParserOptions::BaseOptions
11
+
12
+ def initialize: (Array[String] args, PgEventstore::CLI::ParserOptions::BaseOptions options) -> void
13
+
14
+ def parse: -> [Array[String], PgEventstore::CLI::ParserOptions::BaseOptions]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module Parsers
4
+ class DefaultParser
5
+ def self.banner: -> String
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module PgEventstore
2
+ module CLI
3
+ module Parsers
4
+ class SubscriptionParser
5
+ def self.banner: -> String
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ module PgEventstore
2
+ module CLI
3
+ class TryToDeleteSubscriptionsSet
4
+ def self.try_to_delete: (Symbol config_name, Integer subscriptions_set_id) -> bool
5
+
6
+ attr_reader config_name: Symbol
7
+ attr_reader subscriptions_set_id: Integer
8
+
9
+ def initialize: (Symbol config_name, Integer subscriptions_set_id) -> void
10
+
11
+ def try_to_delete: -> bool
12
+
13
+ private
14
+
15
+ def config: -> PgEventstore::Config
16
+
17
+ def connection: -> PgEventstore::Connection
18
+
19
+ def subscriptions_set_commands_queries: -> PgEventstore::SubscriptionsSetCommandQueries
20
+
21
+ def subscriptions_set_queries: -> PgEventstore::SubscriptionsSetQueries
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ module PgEventstore
2
+ module CLI
3
+ class TryUnlockSubscriptionsSet
4
+ def self.try_unlock: (Symbol config_name, Integer subscriptions_set_id) -> bool
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ module PgEventstore
2
+ module CLI
3
+ class WaitForSubscriptionsSetShutdown
4
+ SHUTDOWN_CHECK_INTERVAL: Float
5
+
6
+ def self.wait_for_shutdown: (Symbol config_name, Integer subscriptions_set_id) -> bool
7
+
8
+ attr_reader config_name: Symbol
9
+ attr_reader subscriptions_set_id: Integer
10
+
11
+ def initialize: (Symbol config_name, Integer subscriptions_set_id) -> void
12
+
13
+ def wait_for_shutdown: -> bool
14
+
15
+ private
16
+
17
+ def config: -> PgEventstore::Config
18
+
19
+ def connection: -> PgEventstore::Connection
20
+
21
+ def find_set!: -> PgEventstore::SubscriptionsSet
22
+
23
+ def subscriptions_set_queries: -> PgEventstore::SubscriptionsSetQueries
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,10 @@
1
+ module PgEventstore
2
+ module CLI
3
+ COMMANDS: Hash[Array[String], singleton(PgEventstore::CLI::Commands::BaseCommand)]
4
+ OPTIONS_PARSER: Hash[String, [singleton(PgEventstore::CLI::Parsers::BaseParser), singleton(PgEventstore::CLI::ParserOptions::BaseOptions)]]
5
+
6
+ def self.callbacks: -> PgEventstore::Callbacks
7
+
8
+ def self.execute: (Array[String] args) -> void
9
+ end
10
+ end
@@ -1,6 +1,23 @@
1
1
  module PgEventstore
2
2
  module Extensions
3
3
  module OptionsExtension
4
+ class Option
5
+ attr_reader name: Symbol
6
+ attr_reader metadata: untyped?
7
+
8
+ def initialize: (Symbol name, ?untyped? metadata) -> untyped
9
+
10
+ def ==: (untyped other_option) -> bool
11
+
12
+ def eql?: (untyped other_option) -> bool
13
+
14
+ def hash: () -> Integer
15
+ end
16
+
17
+ class Options
18
+ def []: (Symbol option) -> PgEventstore::Extensions::OptionsExtension::Option?
19
+ end
20
+
4
21
  def self.included: (untyped klass) -> untyped
5
22
 
6
23
  def initialize: (**untyped options) -> void
@@ -25,7 +42,7 @@ module PgEventstore
25
42
  # _@param_ `opt_name` — option name
26
43
  #
27
44
  # _@param_ `blk` — provide define value using block. It will be later evaluated in the context of your object to determine the default value of the option
28
- def option: (Symbol opt_name) ?{ () -> untyped } -> Symbol
45
+ def option: (Symbol opt_name, ?metadata: untyped?) ?{ () -> untyped } -> Symbol
29
46
 
30
47
  def inherited: (untyped klass) -> untyped
31
48
 
@@ -1,6 +1,10 @@
1
1
  module PgEventstore
2
2
  module CommandHandlers
3
3
  class SubscriptionFeederCommands
4
+ @config_name: Symbol
5
+
6
+ @subscription_feeder: PgEventstore::SubscriptionFeeder
7
+
4
8
  # _@param_ `config_name`
5
9
  #
6
10
  # _@param_ `subscription_feeder`
@@ -11,6 +15,10 @@ module PgEventstore
11
15
  def queries: () -> PgEventstore::SubscriptionsSetCommandQueries
12
16
 
13
17
  def connection: () -> PgEventstore::Connection
18
+
19
+ private
20
+
21
+ def commands: () -> Array[PgEventstore::SubscriptionFeederCommands::Base]
14
22
  end
15
23
  end
16
24
  end