Class: HardWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
lib/hot_catch/hard_worker.rb

Overview

Отвечает за отправку логов на главное приложение

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cancel!(jid) ⇒ Object



23
24
25
# File 'lib/hot_catch/hard_worker.rb', line 23

def self.cancel!(jid)
  Sidekiq.redis {|c| c.setex("cancelled-#{jid}", 86400, 1) }
end

Instance Method Details

#cancelled?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/hot_catch/hard_worker.rb', line 19

def cancelled?
  Sidekiq.redis {|c| c.exists("cancelled-#{jid}") }
end

#perform(body_log, url, try_count) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/hot_catch/hard_worker.rb', line 5

def perform(body_log, url, try_count)
  if try_count > 15
    File.open("log/hot_catch_log_response_errors", 'a'){ |file| file.write body_log.encode('UTF-8', {
      :invalid => :replace,
      :undef   => :replace,
      :replace => '?'
    }) }
  else
    sender = HotCatch::MakeHttpsRequest.new(url, try_count + 1)
    sender.send_log(body_log)
    sender = nil
  end
end