Class: Sqspoller::WorkerTask
- Inherits:
-
Object
- Object
- Sqspoller::WorkerTask
- Defined in:
- lib/sqspoller/worker_task.rb
Constant Summary collapse
- ALLOWED_METHODS =
{ 'post' => :post, 'get' => :get }
Instance Method Summary collapse
-
#initialize(worker_configuration) ⇒ WorkerTask
constructor
A new instance of WorkerTask.
- #process(message, _message_id) ⇒ Object
Constructor Details
#initialize(worker_configuration) ⇒ WorkerTask
Returns a new instance of WorkerTask.
11 12 13 14 15 |
# File 'lib/sqspoller/worker_task.rb', line 11 def initialize worker_configuration @http_method = ALLOWED_METHODS[worker_configuration[:http_method].downcase] @http_url = worker_configuration[:http_url] @timeout = worker_configuration[:timeout] && worker_configuration[:timeout].to_i || 450 end |
Instance Method Details
#process(message, _message_id) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sqspoller/worker_task.rb', line 17 def process(, ) if @http_method RestClient::Request.execute(:method => @http_method, :url => @http_url, :payload => , :headers => HEADERS, :timeout => @timeout, :open_timeout => 5) do |response, request, result| case response.code when 200 return "OK" else raise "Service did not return 200 OK response. #{response.code}" end end else raise "Invalid http_method provided. #{http_method}" end end |