launchdarkly-server-sdk 5.6.0 → 5.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +21 -0
- data/CHANGELOG.md +1 -1
- data/Gemfile.lock +1 -1
- data/lib/ldclient-rb/evaluation.rb +13 -5
- data/lib/ldclient-rb/version.rb +1 -1
- data/spec/evaluation_spec.rb +52 -0
- data/spec/integrations/consul_feature_store_spec.rb +1 -1
- data/spec/integrations/dynamodb_feature_store_spec.rb +1 -1
- data/spec/redis_feature_store_spec.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 634c7b652bbff689dc0d705f75536ee40e76648f
|
4
|
+
data.tar.gz: 7c932f06ef8f16e2f5a13f7c34d19aa834acfeb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81c83640f62d49bed5f91cf9b77f551d0df663491ed96fbfadc69a68a5a09787667c26554a09098bad9b8ba4ef55c78b2e15ab7743c99a3ba43c80b3de48723c
|
7
|
+
data.tar.gz: 72adc3f1ff659659c2093b3f81e680de298a15f20a43df7cc958c9a62040a8670e18505e604254f48401eb8fa5618d61873b7a22ba43fe1fe3a463f16f265a3f
|
@@ -0,0 +1,21 @@
|
|
1
|
+
**Requirements**
|
2
|
+
|
3
|
+
- [ ] I have added test coverage for new or changed functionality
|
4
|
+
- [ ] I have followed the repository's [pull request submission guidelines](../blob/master/CONTRIBUTING.md#submitting-pull-requests)
|
5
|
+
- [ ] I have validated my changes against all supported platform versions
|
6
|
+
|
7
|
+
**Related issues**
|
8
|
+
|
9
|
+
Provide links to any issues in this repository or elsewhere relating to this pull request.
|
10
|
+
|
11
|
+
**Describe the solution you've provided**
|
12
|
+
|
13
|
+
Provide a clear and concise description of what you expect to happen.
|
14
|
+
|
15
|
+
**Describe alternatives you've considered**
|
16
|
+
|
17
|
+
Provide a clear and concise description of any alternative solutions or features you've considered.
|
18
|
+
|
19
|
+
**Additional context**
|
20
|
+
|
21
|
+
Add any other context about the pull request here.
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,7 @@
|
|
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
|
-
## [5.6.0] - 2019-08-
|
5
|
+
## [5.6.0] - 2019-08-28
|
6
6
|
### Added:
|
7
7
|
- Added support for upcoming LaunchDarkly experimentation features. See `LDClient.track()`.
|
8
8
|
|
data/Gemfile.lock
CHANGED
@@ -323,20 +323,28 @@ module LaunchDarkly
|
|
323
323
|
end
|
324
324
|
|
325
325
|
def variation_index_for_user(flag, rule, user)
|
326
|
-
|
327
|
-
|
328
|
-
|
326
|
+
variation = rule[:variation]
|
327
|
+
return variation if !variation.nil? # fixed variation
|
328
|
+
rollout = rule[:rollout]
|
329
|
+
return nil if rollout.nil?
|
330
|
+
variations = rollout[:variations]
|
331
|
+
if !variations.nil? && variations.length > 0 # percentage rollout
|
329
332
|
rollout = rule[:rollout]
|
330
333
|
bucket_by = rollout[:bucketBy].nil? ? "key" : rollout[:bucketBy]
|
331
334
|
bucket = bucket_user(user, flag[:key], bucket_by, flag[:salt])
|
332
335
|
sum = 0;
|
333
|
-
|
336
|
+
variations.each do |variate|
|
334
337
|
sum += variate[:weight].to_f / 100000.0
|
335
338
|
if bucket < sum
|
336
339
|
return variate[:variation]
|
337
340
|
end
|
338
341
|
end
|
339
|
-
|
342
|
+
# The user's bucket value was greater than or equal to the end of the last bucket. This could happen due
|
343
|
+
# to a rounding error, or due to the fact that we are scaling to 100000 rather than 99999, or the flag
|
344
|
+
# data could contain buckets that don't actually add up to 100000. Rather than returning an error in
|
345
|
+
# this case (or changing the scaling, which would potentially change the results for *all* users), we
|
346
|
+
# will simply put the user in the last bucket.
|
347
|
+
variations[-1][:variation]
|
340
348
|
else # the rule isn't well-formed
|
341
349
|
nil
|
342
350
|
end
|
data/lib/ldclient-rb/version.rb
CHANGED
data/spec/evaluation_spec.rb
CHANGED
@@ -560,6 +560,58 @@ describe LaunchDarkly::Evaluation do
|
|
560
560
|
end
|
561
561
|
end
|
562
562
|
|
563
|
+
describe "variation_index_for_user" do
|
564
|
+
it "matches bucket" do
|
565
|
+
user = { key: "userkey" }
|
566
|
+
flag_key = "flagkey"
|
567
|
+
salt = "salt"
|
568
|
+
|
569
|
+
# First verify that with our test inputs, the bucket value will be greater than zero and less than 100000,
|
570
|
+
# so we can construct a rollout whose second bucket just barely contains that value
|
571
|
+
bucket_value = (bucket_user(user, flag_key, "key", salt) * 100000).truncate()
|
572
|
+
expect(bucket_value).to be > 0
|
573
|
+
expect(bucket_value).to be < 100000
|
574
|
+
|
575
|
+
bad_variation_a = 0
|
576
|
+
matched_variation = 1
|
577
|
+
bad_variation_b = 2
|
578
|
+
rule = {
|
579
|
+
rollout: {
|
580
|
+
variations: [
|
581
|
+
{ variation: bad_variation_a, weight: bucket_value }, # end of bucket range is not inclusive, so it will *not* match the target value
|
582
|
+
{ variation: matched_variation, weight: 1 }, # size of this bucket is 1, so it only matches that specific value
|
583
|
+
{ variation: bad_variation_b, weight: 100000 - (bucket_value + 1) }
|
584
|
+
]
|
585
|
+
}
|
586
|
+
}
|
587
|
+
flag = { key: flag_key, salt: salt }
|
588
|
+
|
589
|
+
result_variation = variation_index_for_user(flag, rule, user)
|
590
|
+
expect(result_variation).to be matched_variation
|
591
|
+
end
|
592
|
+
|
593
|
+
it "uses last bucket if bucket value is equal to total weight" do
|
594
|
+
user = { key: "userkey" }
|
595
|
+
flag_key = "flagkey"
|
596
|
+
salt = "salt"
|
597
|
+
|
598
|
+
bucket_value = (bucket_user(user, flag_key, "key", salt) * 100000).truncate()
|
599
|
+
|
600
|
+
# We'll construct a list of variations that stops right at the target bucket value
|
601
|
+
rule = {
|
602
|
+
rollout: {
|
603
|
+
variations: [
|
604
|
+
{ variation: 0, weight: bucket_value }
|
605
|
+
]
|
606
|
+
}
|
607
|
+
}
|
608
|
+
flag = { key: flag_key, salt: salt }
|
609
|
+
|
610
|
+
result_variation = variation_index_for_user(flag, rule, user)
|
611
|
+
expect(result_variation).to be 0
|
612
|
+
end
|
613
|
+
end
|
614
|
+
|
563
615
|
describe "bucket_user" do
|
564
616
|
it "gets expected bucket values for specific keys" do
|
565
617
|
user = { key: "userKeyA" }
|
@@ -31,7 +31,7 @@ end
|
|
31
31
|
describe LaunchDarkly::RedisFeatureStore do
|
32
32
|
subject { LaunchDarkly::RedisFeatureStore }
|
33
33
|
|
34
|
-
|
34
|
+
break if ENV['LD_SKIP_DATABASE_TESTS'] == '1'
|
35
35
|
|
36
36
|
# These tests will all fail if there isn't a Redis instance running on the default port.
|
37
37
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: launchdarkly-server-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.6.
|
4
|
+
version: 5.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LaunchDarkly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-dynamodb
|
@@ -237,6 +237,7 @@ files:
|
|
237
237
|
- ".circleci/config.yml"
|
238
238
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
239
239
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
240
|
+
- ".github/pull_request_template.md"
|
240
241
|
- ".gitignore"
|
241
242
|
- ".hound.yml"
|
242
243
|
- ".ldrelease/config.yml"
|