Class: DaimonSkycrawlers::Consumer::HTTPResponse

Inherits:
Base
  • Object
show all
Includes:
SongkickQueue::Consumer
Defined in:
lib/daimon_skycrawlers/consumer/http_response.rb

Overview

HTTP response consumer class

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DaimonSkycrawlers::ConfigMixin

#initialize

Methods included from LoggerMixin

included, #initialize

Class Method Details

.default_processorObject



46
47
48
# File 'lib/daimon_skycrawlers/consumer/http_response.rb', line 46

def default_processor
  DaimonSkycrawlers::Processor::Default.new
end

.processorsObject



39
40
41
# File 'lib/daimon_skycrawlers/consumer/http_response.rb', line 39

def processors
  @processors ||= []
end

.queue_nameObject



53
54
55
# File 'lib/daimon_skycrawlers/consumer/http_response.rb', line 53

def queue_name
  "#{DaimonSkycrawlers.configuration.queue_name_prefix}.http-response"
end

.register(processor) ⇒ void .register {|message| ... } ⇒ void

Register a processor

Overloads:

  • .register(processor) ⇒ void

    This method returns an undefined value.

    Parameters:

    • processor (Processor)

      instance which implements ‘call` method

  • .register {|message| ... } ⇒ void

    This method returns an undefined value.

    Yields:

    • (message)

      register given block as a processor

    Yield Parameters:

    • message (Hash)

      A message from queue

    Yield Returns:

    • (void)


28
29
30
31
32
33
34
# File 'lib/daimon_skycrawlers/consumer/http_response.rb', line 28

def register(processor = nil, &block)
  if block_given?
    processors << block
  else
    processors << processor
  end
end

Instance Method Details

#process(message) ⇒ Object



63
64
65
66
67
68
69
70
71
72
# File 'lib/daimon_skycrawlers/consumer/http_response.rb', line 63

def process(message)
  if self.class.processors.empty?
    processors = [self.class.default_processor]
  else
    processors = self.class.processors
  end
  processors.each do |processor|
    processor.process(message)
  end
end