Class: Featureflip::DataSource::PollingHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/featureflip/data_source/polling.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_client:, config:, on_update:, on_error:) ⇒ PollingHandler

Returns a new instance of PollingHandler.



4
5
6
7
8
9
10
11
# File 'lib/featureflip/data_source/polling.rb', line 4

def initialize(http_client:, config:, on_update:, on_error:)
  @http_client = http_client
  @config = config
  @on_update = on_update
  @on_error = on_error
  @stop_flag = false
  @thread = nil
end

Instance Method Details

#startObject



13
14
15
16
# File 'lib/featureflip/data_source/polling.rb', line 13

def start
  @stop_flag = false
  @thread = Thread.new { run }
end

#stopObject



18
19
20
21
22
23
# File 'lib/featureflip/data_source/polling.rb', line 18

def stop
  @stop_flag = true
  @thread&.wakeup rescue nil
  @thread&.join(5)
  @thread = nil
end