Class: LaunchDarkly::StreamProcessor
- Inherits:
-
Object
- Object
- LaunchDarkly::StreamProcessor
- Defined in:
- lib/ldclient-rb/stream.rb
Instance Method Summary collapse
-
#initialize(sdk_key, config, requestor) ⇒ StreamProcessor
constructor
A new instance of StreamProcessor.
- #initialized? ⇒ Boolean
- #start ⇒ Object
Constructor Details
#initialize(sdk_key, config, requestor) ⇒ StreamProcessor
Returns a new instance of StreamProcessor.
13 14 15 16 17 18 19 20 |
# File 'lib/ldclient-rb/stream.rb', line 13 def initialize(sdk_key, config, requestor) @sdk_key = sdk_key @config = config @store = config.feature_store @requestor = requestor @initialized = Concurrent::AtomicBoolean.new(false) @started = Concurrent::AtomicBoolean.new(false) end |
Instance Method Details
#initialized? ⇒ Boolean
22 23 24 |
# File 'lib/ldclient-rb/stream.rb', line 22 def initialized? @initialized.value end |
#start ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ldclient-rb/stream.rb', line 26 def start return unless @started.make_true @config.logger.info("[LDClient] Initializing stream connection") headers = { 'Authorization' => @sdk_key, 'User-Agent' => 'RubyClient/' + LaunchDarkly::VERSION } opts = {:headers => headers, :with_credentials => true} @es = Celluloid::EventSource.new(@config.stream_uri + "/flags", opts) do |conn| conn.on(PUT) { || (, PUT) } conn.on(PATCH) { || (, PATCH) } conn.on(DELETE) { || (, DELETE) } conn.on(INDIRECT_PUT) { || (, INDIRECT_PUT) } conn.on(INDIRECT_PATCH) { || (, INDIRECT_PATCH) } conn.on_error do || @config.logger.error("[LDClient] Error connecting to stream. Status code: #{[:status_code]}") end end end |