Skip to content

Commit 3add43e

Browse files
authored
Merge pull request #75 from launchdarkly/jko/fix-indirect-patch
Fixes for indirect patch
2 parents bb76f68 + 4e84437 commit 3add43e

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to the LaunchDarkly Ruby SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [2.0.3] - 2016-10-21
6+
## Fixed
7+
- Indirect stream events are now correctly processed
8+
59
## [2.0.2] - 2016-08-08
610
## Changed
711
- The default logger now logs at `info` level

lib/ldclient-rb/stream.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,26 @@ def start
4747
end
4848

4949
def process_message(message, method)
50-
message = JSON.parse(message.data, symbolize_names: true)
5150
@config.logger.debug("[LDClient] Stream received #{method} message")
5251
if method == PUT
52+
message = JSON.parse(message.data, symbolize_names: true)
5353
@store.init(message)
5454
@initialized.make_true
5555
@config.logger.info("[LDClient] Stream initialized")
5656
elsif method == PATCH
57+
message = JSON.parse(message.data, symbolize_names: true)
5758
@store.upsert(message[:path][1..-1], message[:data])
5859
elsif method == DELETE
60+
message = JSON.parse(message.data, symbolize_names: true)
5961
@store.delete(message[:path][1..-1], message[:version])
6062
elsif method == INDIRECT_PUT
6163
@store.init(@requestor.request_all_flags)
6264
@initialized.make_true
6365
@config.logger.info("[LDClient] Stream initialized (via indirect message)")
6466
elsif method == INDIRECT_PATCH
65-
@store.upsert(@requestor.request_flag(message[:data]))
67+
@store.upsert(message.data, @requestor.request_flag(message.data))
6668
else
67-
@config.logger.error("[LDClient] Unknown message received: #{method}")
69+
@config.logger.warn("[LDClient] Unknown message received: #{method}")
6870
end
6971
end
7072

lib/ldclient-rb/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module LaunchDarkly
2-
VERSION = "2.0.2"
2+
VERSION = "2.0.3"
33
end

spec/stream_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
processor.send(:process_message, delete_message, LaunchDarkly::DELETE)
5454
expect(processor.instance_variable_get(:@store).get("key")).to eq(nil)
5555
end
56-
it "will log an error if the method is not recognized" do
57-
expect(processor.instance_variable_get(:@config).logger).to receive :error
56+
it "will log a warning if the method is not recognized" do
57+
expect(processor.instance_variable_get(:@config).logger).to receive :warn
5858
processor.send(:process_message, put_message, "get")
5959
end
6060
end

0 commit comments

Comments
 (0)