module BitsDealer::Monitor

Attributes

monitor[R]

Public Instance Methods

start_monitors() click to toggle source
# File lib/bits_dealer/commands/monitor.rb, line 7
def start_monitors
  @monitor_data = OpenStruct.new({
    tickers: [],
    stats: {}
  })

  _monit_tickers
  _process_stats
end

Private Instance Methods

monitor_tickers() click to toggle source
# File lib/bits_dealer/commands/monitor.rb, line 21
def monitor_tickers
  Thread.kill(@tickers_thread) if @tickers_thread
  Thread.abort_on_exception = true
  @tickers_thread = Thread.new do
    loop do
      books = BitsDealer::Books::ALL_BOOKS
      tickers = Parallel.map(books) do |book|
        with_retries(:max_tries => 3) { Bitsor.ticker(book: book.id) }
      end
      @monitor_data.tickers = [{ created_at: Time.now.to_i, data: tickers }] + @monitor_data.tickers[0..99]
      sleep 15
    end
  end
end
process_stats() click to toggle source
# File lib/bits_dealer/commands/monitor.rb, line 36
def process_stats

end