Sha256: 4fa6d632dae39ecfd1e7965f9f9fd7f3dd89729c22942bdf6fb9888897a76d1c

Contents?: true

Size: 1.03 KB

Versions: 10

Compression:

Stored size: 1.03 KB

Contents

module DispatchRider
  class Runner

    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
        puts "Running..."
        @subscriber.process
      end
    end

    private

    def config
      DispatchRider.config
    end

    def callbacks
      @callbacks ||= Callbacks::Access.new(config.callbacks)
    end

    def ready
      puts "Creating subscriber..."
      @subscriber = config.subscriber.new

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

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

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

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dispatch-rider-0.2.6 lib/dispatch-rider/runner.rb
dispatch-rider-0.2.5 lib/dispatch-rider/runner.rb
dispatch-rider-0.2.4 lib/dispatch-rider/runner.rb
dispatch-rider-0.2.3 lib/dispatch-rider/runner.rb
dispatch-rider-0.2.2 lib/dispatch-rider/runner.rb
dispatch-rider-0.2.1 lib/dispatch-rider/runner.rb
dispatch-rider-0.2.0 lib/dispatch-rider/runner.rb
dispatch-rider-0.1.2 lib/dispatch-rider/runner.rb
dispatch-rider-0.1.1.1 lib/dispatch-rider/runner.rb
dispatch-rider-0.1.0 lib/dispatch-rider/runner.rb