Class: Featureflip::DataSource::StreamingHandler
- Inherits:
-
Object
- Object
- Featureflip::DataSource::StreamingHandler
- Defined in:
- lib/featureflip/data_source/streaming.rb
Instance Method Summary collapse
-
#initialize(sdk_key:, config:, http_client:, on_flag_updated:, on_flag_deleted:, on_segment_updated:, on_error:, on_give_up: nil) ⇒ StreamingHandler
constructor
A new instance of StreamingHandler.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(sdk_key:, config:, http_client:, on_flag_updated:, on_flag_deleted:, on_segment_updated:, on_error:, on_give_up: nil) ⇒ StreamingHandler
Returns a new instance of StreamingHandler.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/featureflip/data_source/streaming.rb', line 8 def initialize(sdk_key:, config:, http_client:, on_flag_updated:, on_flag_deleted:, on_segment_updated:, on_error:, on_give_up: nil) @sdk_key = sdk_key @config = config @http_client = http_client @on_flag_updated = on_flag_updated @on_flag_deleted = on_flag_deleted @on_segment_updated = on_segment_updated @on_error = on_error @on_give_up = on_give_up @stop_flag = false @thread = nil @retry_count = 0 @current_event_type = nil @current_data = nil end |
Instance Method Details
#start ⇒ Object
24 25 26 27 28 |
# File 'lib/featureflip/data_source/streaming.rb', line 24 def start @stop_flag = false @retry_count = 0 @thread = Thread.new { run } end |
#stop ⇒ Object
30 31 32 33 34 35 |
# File 'lib/featureflip/data_source/streaming.rb', line 30 def stop @stop_flag = true @thread&.wakeup rescue nil @thread&.join(5) @thread = nil end |