ldclient-rb 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5624d2c634cd8bc37ee54d2215e4150c754a2de7
4
- data.tar.gz: da595a32a6ed8f80625318141639d1ddc26bed7f
3
+ metadata.gz: 2f3d50fce0854f03fc54889c382dff25d1bc7f07
4
+ data.tar.gz: 51dfad8e56e09fa7da457d55863223b3a64cd9f6
5
5
  SHA512:
6
- metadata.gz: 79f7bff1fd78fdc74370ae3604a13da553cdc9052d4a3c294470c51ca7f4969c93b8f9a317bc906f5b90f0d7d2d997e7a64738e7f209a0267ede8eedfb74b952
7
- data.tar.gz: f3288d3da6869ee47c2785d34d190d63391ba0d0df59cb3b135c939589f52e6cdc9645b7cd1503d51822214888b65ba0221e2d4341513633ee9ef03caa860fc9
6
+ metadata.gz: d3e036b4cf2ff3c032e3260be2fa73bb22c4ef0dc79467a8c877713d388b139ef4f76f3c5b666fdc0acf8455f909ef8b38b729d2950edb309fa8ee5d7db6ea30
7
+ data.tar.gz: 5d16aa332570cd295243e4ba507bfc99cbf8f30e12bca72d96767050d9ebfc3a16545bc118c0e8a36535dce447c81228913f536661d7f20c49be6aa270180dd0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to the LaunchDarkly Ruby SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
4
4
 
5
+ ## [3.0.1] - 2018-02-26
6
+ ### Fixed
7
+ - Fixed a bug that could prevent very large feature flags from being updated in streaming mode.
8
+
9
+
5
10
  ## [3.0.0] - 2018-02-22
6
11
  ### Added
7
12
  - Support for a new LaunchDarkly feature: reusable user segments.
@@ -18,18 +18,10 @@ module LaunchDarkly
18
18
  end
19
19
  end
20
20
 
21
- def request_all_flags()
22
- make_request("/sdk/latest-flags")
23
- end
24
-
25
21
  def request_flag(key)
26
22
  make_request("/sdk/latest-flags/" + key)
27
23
  end
28
24
 
29
- def request_all_segments()
30
- make_request("/sdk/latest-segments")
31
- end
32
-
33
25
  def request_segment(key)
34
26
  make_request("/sdk/latest-segments/" + key)
35
27
  end
@@ -110,13 +110,13 @@ module LaunchDarkly
110
110
  @initialized.make_true
111
111
  @config.logger.info("[LDClient] Stream initialized (via indirect message)")
112
112
  elsif method == INDIRECT_PATCH
113
- key = feature_key_for_path(message.data)
113
+ key = key_for_path(FEATURES, message.data)
114
114
  if key
115
115
  @feature_store.upsert(FEATURES, @requestor.request_flag(key))
116
116
  else
117
- key = segment_key_for_path(message.data)
117
+ key = key_for_path(SEGMENTS, message.data)
118
118
  if key
119
- @feature_store.upsert(SEGMENTS, key, @requestor.request_segment(key))
119
+ @feature_store.upsert(SEGMENTS, @requestor.request_segment(key))
120
120
  end
121
121
  end
122
122
  else
@@ -1,3 +1,3 @@
1
1
  module LaunchDarkly
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
@@ -19,12 +19,12 @@ describe LaunchDarkly::Requestor do
19
19
  allow(faraday).to receive(:get) do |*args, &block|
20
20
  req = double(Faraday::Request, :headers => {}, :options => Faraday::RequestOptions.new)
21
21
  block.call(req)
22
- expect(args).to eq ['http://ld.com/sdk/latest-flags']
22
+ expect(args).to eq ['http://ld.com/sdk/latest-all']
23
23
  expect(req.options.proxy[:uri]).to eq URI("http://proxy.com")
24
24
  double(body: '{"foo": "bar"}', status: 200, headers: {})
25
25
  end
26
26
 
27
- requestor.request_all_flags()
27
+ requestor.request_all_data()
28
28
  end
29
29
  end
30
30
  describe "without a proxy" do
@@ -42,11 +42,11 @@ describe LaunchDarkly::Requestor do
42
42
  allow(faraday).to receive(:get) do |*args, &block|
43
43
  req = double(Faraday::Request, :headers => {}, :options => Faraday::RequestOptions.new)
44
44
  block.call(req)
45
- expect(args).to eq ['http://ld.com/sdk/latest-flags']
45
+ expect(args).to eq ['http://ld.com/sdk/latest-all']
46
46
  expect(req.options.proxy).to eq nil
47
47
  double(body: '{"foo": "bar"}', status: 200, headers: {})
48
48
  end
49
- requestor.request_all_flags()
49
+ requestor.request_all_data()
50
50
  end
51
51
  end
52
52
  end
data/spec/stream_spec.rb CHANGED
@@ -1,42 +1,10 @@
1
1
  require "spec_helper"
2
2
  require 'ostruct'
3
3
 
4
- describe LaunchDarkly::InMemoryFeatureStore do
5
- subject { LaunchDarkly::InMemoryFeatureStore }
6
-
7
- include LaunchDarkly
8
-
9
- let(:store) { subject.new }
10
- let(:key) { :asdf }
11
- let(:feature) { { key: "asdf", value: "qwer", version: 0 } }
12
-
13
- describe '#all' do
14
- it "will get all keys" do
15
- store.upsert(LaunchDarkly::FEATURES, feature)
16
- data = store.all(LaunchDarkly::FEATURES)
17
- expect(data).to eq(key => feature)
18
- end
19
- it "will not get deleted keys" do
20
- store.upsert(LaunchDarkly::FEATURES, feature)
21
- store.delete(LaunchDarkly::FEATURES, key, 1)
22
- data = store.all(LaunchDarkly::FEATURES)
23
- expect(data).to eq({})
24
- end
25
- end
26
-
27
- describe '#initialized?' do
28
- it "will return whether the store has been initialized" do
29
- expect(store.initialized?).to eq false
30
- store.init(key => feature)
31
- expect(store.initialized?).to eq true
32
- end
33
- end
34
- end
35
-
36
4
  describe LaunchDarkly::StreamProcessor do
37
5
  subject { LaunchDarkly::StreamProcessor }
38
6
  let(:config) { LaunchDarkly::Config.new }
39
- let(:requestor) { LaunchDarkly::Requestor.new("sdk_key", config)}
7
+ let(:requestor) { double() }
40
8
  let(:processor) { subject.new("sdk_key", config, requestor) }
41
9
 
42
10
  describe '#process_message' do
@@ -45,6 +13,9 @@ describe LaunchDarkly::StreamProcessor do
45
13
  let(:patch_seg_message) { OpenStruct.new({data: '{"path": "/segments/key", "data": {"key": "asdf", "version": 1}}'}) }
46
14
  let(:delete_flag_message) { OpenStruct.new({data: '{"path": "/flags/key", "version": 2}'}) }
47
15
  let(:delete_seg_message) { OpenStruct.new({data: '{"path": "/segments/key", "version": 2}'}) }
16
+ let(:indirect_patch_flag_message) { OpenStruct.new({data: "/flags/key"}) }
17
+ let(:indirect_patch_segment_message) { OpenStruct.new({data: "/segments/key"}) }
18
+
48
19
  it "will accept PUT methods" do
49
20
  processor.send(:process_message, put_message, LaunchDarkly::PUT)
50
21
  expect(config.feature_store.get(LaunchDarkly::FEATURES, "asdf")).to eq(key: "asdf")
@@ -68,6 +39,18 @@ describe LaunchDarkly::StreamProcessor do
68
39
  processor.send(:process_message, delete_seg_message, LaunchDarkly::DELETE)
69
40
  expect(config.feature_store.get(LaunchDarkly::SEGMENTS, "key")).to eq(nil)
70
41
  end
42
+ it "will accept INDIRECT PATCH method for flags" do
43
+ flag = { key: 'key', version: 1 }
44
+ allow(requestor).to receive(:request_flag).with(flag[:key]).and_return(flag)
45
+ processor.send(:process_message, indirect_patch_flag_message, LaunchDarkly::INDIRECT_PATCH);
46
+ expect(config.feature_store.get(LaunchDarkly::FEATURES, flag[:key])).to eq(flag)
47
+ end
48
+ it "will accept INDIRECT PATCH method for segments" do
49
+ segment = { key: 'key', version: 1 }
50
+ allow(requestor).to receive(:request_segment).with(segment[:key]).and_return(segment)
51
+ processor.send(:process_message, indirect_patch_segment_message, LaunchDarkly::INDIRECT_PATCH);
52
+ expect(config.feature_store.get(LaunchDarkly::SEGMENTS, segment[:key])).to eq(segment)
53
+ end
71
54
  it "will log a warning if the method is not recognized" do
72
55
  expect(processor.instance_variable_get(:@config).logger).to receive :warn
73
56
  processor.send(:process_message, put_message, "get")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ldclient-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - LaunchDarkly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-22 00:00:00.000000000 Z
11
+ date: 2018-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler