Class: NetuitiveRubyApi::SampleSchedule

Inherits:
Object
  • Object
show all
Defined in:
lib/netuitive_ruby_api/sample_schedule.rb

Class Method Summary collapse

Class Method Details

.start(interval) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/netuitive_ruby_api/sample_schedule.rb', line 3

def self.start(interval)
  @@thread = Thread.new do
    loop do
      sleep(interval)
      Thread.new do
        NetuitiveRubyApi::NetuitiveLogger.log.debug 'started sample job'
        NetuitiveRubyApi::ErrorLogger.guard('error during sample job') do
          NetuitiveRubyAPI.flush_samples
        end
        NetuitiveRubyApi::NetuitiveLogger.log.debug 'finished sample job'
      end
    end
  end
end

.stopObject



18
19
20
# File 'lib/netuitive_ruby_api/sample_schedule.rb', line 18

def self.stop
  @@thread.kill if defined? @@thread
end