Class: Stackify::LogsSender

Inherits:
HttpClient show all
Defined in:
lib/stackify/logs_sender.rb

Constant Summary collapse

LOGS_URI =
URI("#{Stackify.configuration.base_api_url}/Log/Save")

Constants inherited from HttpClient

HttpClient::HEADERS

Instance Attribute Summary

Attributes inherited from HttpClient

#errors, #response

Instance Method Summary collapse

Instance Method Details

#send_remained_msgsObject



15
16
17
18
19
20
21
22
23
# File 'lib/stackify/logs_sender.rb', line 15

def send_remained_msgs
  if Stackify.working?
    Stackify.internal_log :warn, 'Sending of remained msgs is possible when Stackify is terminating work.'
  else
    worker = Stackify::Worker.new 'RemainedJob worker'
    task = send_all_remained_msgs_task Stackify.msgs_queue.pop_all
    worker.perform 2, task
  end
end

#startObject



6
7
8
9
10
11
12
13
# File 'lib/stackify/logs_sender.rb', line 6

def start
  worker = Stackify::Worker.new 'Main sending thread'
  task = Stackify::ScheduleTask.new do
    send_logs
  end
  worker.async_perform Stackify.configuration.send_interval, task
  Stackify.internal_log :debug, 'LogsSender: main sending thread is started'
end