Sha256: f1ae73a5780cb7074fb0c12bbd1cb538e6c718ae57c8661c2373c77cea4450f6

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

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

13 entries across 13 versions & 1 rubygems

Version Path
dispatch-rider-1.9.0 lib/dispatch-rider/runner.rb
dispatch-rider-1.8.6 lib/dispatch-rider/runner.rb
dispatch-rider-1.8.5 lib/dispatch-rider/runner.rb
dispatch-rider-1.8.4 lib/dispatch-rider/runner.rb
dispatch-rider-1.8.3 lib/dispatch-rider/runner.rb
dispatch-rider-1.8.2 lib/dispatch-rider/runner.rb
dispatch-rider-1.8.1 lib/dispatch-rider/runner.rb
dispatch-rider-1.8.0 lib/dispatch-rider/runner.rb
dispatch-rider-1.7.2 lib/dispatch-rider/runner.rb
dispatch-rider-1.7.1 lib/dispatch-rider/runner.rb
dispatch-rider-1.7.0 lib/dispatch-rider/runner.rb
dispatch-rider-1.6.2 lib/dispatch-rider/runner.rb
dispatch-rider-1.6.1 lib/dispatch-rider/runner.rb