Sha256: d2a4713cc6a6256e42d0049a0c10af2b54092e161034bfe22968c81ff1b53497

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

module PgEventstore
  module CLI
    module Commands
      module CallbackHandlers
        class StartCmdHandlers
          include Extensions::CallbackHandlersExtension

          class << self
            # @param subscription_managers [Set<PgEventstore::SubscriptionsManager>]
            # @param manager [PgEventstore::SubscriptionsManager]
            # @return [void]
            def register_managers(subscription_managers, manager)
              subscription_managers.add(manager)
            end

            # @param action [Proc]
            # @param manager [PgEventstore::SubscriptionsManager]
            # @return [void]
            def handle_start_up(action, manager)
              action.call
            rescue SubscriptionAlreadyLockedError => error
              PgEventstore.logger&.error(
                <<~TEXT
                  Subscription #{error.name.inspect} from #{error.set.inspect} set is locked under \
                  SubscriptionsSet##{error.lock_id}. Trying to unlock...
                TEXT
              )
              raise unless TryUnlockSubscriptionsSet.try_unlock(manager.config_name, error.lock_id)
              retry
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pg_eventstore-1.7.0 lib/pg_eventstore/cli/commands/callback_handlers/start_cmd_handlers.rb
pg_eventstore-1.6.0 lib/pg_eventstore/cli/commands/callback_handlers/start_cmd_handlers.rb