Sha256: 6b13a6cbdcad7e00b8ae41dadf80cba824c2d8b9f0eb575b20662992f28487f7

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

module PgEventstore
  class CommandsHandlerHandlers
    include Extensions::CallbackHandlersExtension

    class << self
      # @param config_name [Symbol]
      # @param subscription_feeder [PgEventstore::SubscriptionFeeder]
      # @return [void]
      def process_feeder_commands(config_name, subscription_feeder)
        CommandHandlers::SubscriptionFeederCommands.new(config_name, subscription_feeder).process
      end

      # @param config_name [Symbol]
      # @param runners [Array<PgEventstore::SubscriptionRunner>]
      # @param subscription_feeder [PgEventstore::SubscriptionFeeder]
      # @return [void]
      def process_runners_commands(config_name, runners, subscription_feeder)
        CommandHandlers::SubscriptionRunnersCommands.new(config_name, runners, subscription_feeder.id).process
      end

      # @param basic_runner [PgEventstore::BasicRunner]
      # @param restart_delay [Integer]
      # @param error [StandardError]
      # @return [void]
      def restore_runner(basic_runner, restart_delay, error)
        PgEventstore.logger&.error "PgEventstore::CommandsHandler: Error occurred: #{error.message}"
        PgEventstore.logger&.error "PgEventstore::CommandsHandler: Backtrace: #{error.backtrace&.join("\n")}"
        PgEventstore.logger&.error "PgEventstore::CommandsHandler: Trying to auto-repair in #{restart_delay} seconds..."
        Thread.new do
          sleep restart_delay
          basic_runner.restore
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pg_eventstore-1.7.0 lib/pg_eventstore/subscriptions/callback_handlers/commands_handler_handlers.rb
pg_eventstore-1.6.0 lib/pg_eventstore/subscriptions/callback_handlers/commands_handler_handlers.rb
pg_eventstore-1.5.0 lib/pg_eventstore/subscriptions/callback_handlers/commands_handler_handlers.rb