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")
=
{
'Authorization' => @sdk_key,
'User-Agent' => 'RubyClient/' + LaunchDarkly::VERSION
}
opts = {:headers => , :with_credentials => true}
@es = Celluloid::EventSource.new(@config.stream_uri + "/flags", opts) do |conn|
conn.on(PUT) { |message| process_message(message, PUT) }
conn.on(PATCH) { |message| process_message(message, PATCH) }
conn.on(DELETE) { |message| process_message(message, DELETE) }
conn.on(INDIRECT_PUT) { |message| process_message(message, INDIRECT_PUT) }
conn.on(INDIRECT_PATCH) { |message| process_message(message, INDIRECT_PATCH) }
conn.on_error do |message|
@config.logger.error("[LDClient] Error connecting to stream. Status code: #{message[:status_code]}")
end
end
end
|