Class: Kameleoon::RealTime::RealTimeConfigurationService
- Inherits:
-
Object
- Object
- Kameleoon::RealTime::RealTimeConfigurationService
- Defined in:
- lib/kameleoon/real_time/real_time_configuration_service.rb
Overview
RealTimeConfigurationService is used for fetching updates of configuration (experiments and feature flags) in real time.
Instance Method Summary collapse
-
#close ⇒ Object
Closes the connection to the server.
-
#initialize(url, update_handler, sse_request_source = nil) ⇒ RealTimeConfigurationService
constructor
Parametrized initializer.
Constructor Details
#initialize(url, update_handler, sse_request_source = nil) ⇒ RealTimeConfigurationService
Parametrized initializer.
is synchronously called for gotten RealTimeEvent objects.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kameleoon/real_time/real_time_configuration_service.rb', line 25 def initialize(url, update_handler, sse_request_source = nil) @url = url @update_handler = update_handler @need_close = false @headers = { 'Accept': 'text/event-stream', 'Cache-Control': 'no-cache', 'Connection': 'Keep-Alive' } @sse_request_source = sse_request_source @sse_thread = nil @sse_client = nil create_sse_client end |
Instance Method Details
#close ⇒ Object
Closes the connection to the server.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/kameleoon/real_time/real_time_configuration_service.rb', line 42 def close return if @need_close Logging::KameleoonLogger.info('Real-time configuration service is shutting down') @need_close = true return if @sse_thread.nil? @sse_thread.kill @sse_thread = nil @sse_client&.call_close_handler end |