Sha256: be217de5d4a73b492031bb5fb5d37081b217dc35bb481e79b9501ff6ba70a44f

Contents?: true

Size: 1.14 KB

Versions: 14

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module PgEventstore
  module CommandHandlers
    class SubscriptionRunnersCommands
      # @param config_name [Symbol]
      # @param runners [Array<PgEventstore::SubscriptionRunner>]
      # @param subscriptions_set_id [Integer]
      def initialize(config_name, runners, subscriptions_set_id)
        @config_name = config_name
        @runners = runners.to_h { |runner| [runner.id, runner] }
        @subscriptions_set_id = subscriptions_set_id
      end

      # Look up commands for all given SubscriptionRunner-s and execute them
      # @return [void]
      def process
        queries.find_commands(@runners.keys, subscriptions_set_id: @subscriptions_set_id).each do |command|
          command.exec_cmd(@runners[command.subscription_id]) if @runners[command.subscription_id]
          queries.delete(command.id)
        end
      end

      private

      # @return [PgEventstore::SubscriptionCommandQueries]
      def queries
        SubscriptionCommandQueries.new(connection)
      end

      # @return [PgEventstore::Connection]
      def connection
        PgEventstore.connection(@config_name)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pg_eventstore-1.5.0 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.4.0 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.3.4 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.3.3 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.3.2 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.3.1 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.3.0 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.2.0 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.1.5 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.1.4 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.1.3 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.1.2 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.1.1 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb
pg_eventstore-1.1.0 lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb