Sha256: 80c961e4c1705a5a5001d2d7de4054e02b9f0a2dae8615595c8e569de3f3dc8b

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module DispatchRider
  class Runner
    include Callbacks::Support

    def self.run
      new.process
    end

    def initialize
      callbacks.invoke(:initialize) do
        ready
        set_queue_from_config
      end
    end
    private_class_method :new

    def process
      callbacks.invoke(:process) do
        logger.info "Running..."
        @subscriber.process
      end
    end

    private

    delegate :config, to: :DispatchRider
    delegate :logger, to: :config

    def ready
      logger.info "Creating subscriber..."
      @subscriber = config.subscriber.new

      config.handlers.each do |handler_name|
        logger.info "Registering #{handler_name} handler..."
        @subscriber.register_handler(handler_name)
      end
    end

    def set_queue_from_config
      kind = config.queue_kind
      info = config.queue_info

      logger.info "Setting #{kind} queue @ #{info.to_json} ..."
      @subscriber.register_queue(kind, info)
      @subscriber.setup_demultiplexer(kind, config.error_handler)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dispatch-rider-2.2.0 lib/dispatch-rider/runner.rb