splitclient-rb 4.1.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.txt +8 -0
- data/NEWS +6 -0
- data/README.md +5 -18
- data/lib/splitclient-rb.rb +65 -54
- data/lib/{cache → splitclient-rb/cache}/adapters/memory_adapter.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/adapters/memory_adapters/map_adapter.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/adapters/memory_adapters/queue_adapter.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/adapters/redis_adapter.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/repositories/impressions/memory_repository.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/repositories/impressions/redis_repository.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/repositories/impressions_repository.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/repositories/metrics/memory_repository.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/repositories/metrics/redis_repository.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/repositories/metrics_repository.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/repositories/repository.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/repositories/segments_repository.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/repositories/splits_repository.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/senders/impressions_formatter.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/senders/impressions_sender.rb +1 -1
- data/lib/{cache → splitclient-rb/cache}/senders/metrics_sender.rb +1 -1
- data/lib/{cache → splitclient-rb/cache}/stores/sdk_blocker.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/stores/segment_store.rb +0 -0
- data/lib/{cache → splitclient-rb/cache}/stores/split_store.rb +0 -0
- data/lib/splitclient-rb/clients/localhost_split_client.rb +3 -3
- data/lib/splitclient-rb/clients/split_client.rb +28 -25
- data/lib/{engine → splitclient-rb/engine}/api/client.rb +4 -4
- data/lib/splitclient-rb/engine/api/faraday_middleware/gzip.rb +55 -0
- data/lib/{engine → splitclient-rb/engine}/api/impressions.rb +0 -0
- data/lib/{engine → splitclient-rb/engine}/api/metrics.rb +0 -0
- data/lib/{engine → splitclient-rb/engine}/api/segments.rb +0 -0
- data/lib/{engine → splitclient-rb/engine}/api/splits.rb +0 -0
- data/lib/{engine → splitclient-rb/engine}/evaluator/splitter.rb +2 -2
- data/lib/{engine → splitclient-rb/engine}/matchers/all_keys_matcher.rb +1 -1
- data/lib/{engine → splitclient-rb/engine}/matchers/between_matcher.rb +2 -2
- data/lib/{engine → splitclient-rb/engine}/matchers/combiners.rb +0 -0
- data/lib/{engine → splitclient-rb/engine}/matchers/combining_matcher.rb +10 -8
- data/lib/{engine → splitclient-rb/engine}/matchers/contains_all_matcher.rb +1 -1
- data/lib/{engine → splitclient-rb/engine}/matchers/contains_any_matcher.rb +1 -1
- data/lib/{engine → splitclient-rb/engine}/matchers/contains_matcher.rb +1 -1
- data/lib/splitclient-rb/engine/matchers/dependency_matcher.rb +16 -0
- data/lib/{engine → splitclient-rb/engine}/matchers/ends_with_matcher.rb +1 -1
- data/lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb +21 -0
- data/lib/{engine → splitclient-rb/engine}/matchers/equal_to_matcher.rb +2 -2
- data/lib/{engine → splitclient-rb/engine}/matchers/equal_to_set_matcher.rb +1 -1
- data/lib/{engine → splitclient-rb/engine}/matchers/greater_than_or_equal_to_matcher.rb +2 -2
- data/lib/{engine → splitclient-rb/engine}/matchers/less_than_or_equal_to_matcher.rb +2 -2
- data/lib/splitclient-rb/engine/matchers/matches_string_matcher.rb +23 -0
- data/lib/{engine → splitclient-rb/engine}/matchers/negation_matcher.rb +2 -2
- data/lib/{engine → splitclient-rb/engine}/matchers/part_of_set_matcher.rb +1 -1
- data/lib/{engine → splitclient-rb/engine}/matchers/set_matcher.rb +0 -0
- data/lib/{engine → splitclient-rb/engine}/matchers/starts_with_matcher.rb +1 -1
- data/lib/{engine → splitclient-rb/engine}/matchers/user_defined_segment_matcher.rb +2 -2
- data/lib/{engine → splitclient-rb/engine}/matchers/whitelist_matcher.rb +2 -2
- data/lib/{engine → splitclient-rb/engine}/metrics/binary_search_latency_tracker.rb +0 -0
- data/lib/{engine → splitclient-rb/engine}/metrics/metrics.rb +0 -0
- data/lib/splitclient-rb/engine/models/label.rb +7 -0
- data/lib/{engine → splitclient-rb/engine}/models/split.rb +0 -0
- data/lib/splitclient-rb/engine/models/treatment.rb +3 -0
- data/lib/{engine → splitclient-rb/engine}/parser/condition.rb +21 -0
- data/lib/{engine/parser/split_treatment.rb → splitclient-rb/engine/parser/evaluator.rb} +29 -13
- data/lib/{engine → splitclient-rb/engine}/parser/partition.rb +0 -0
- data/lib/{engine → splitclient-rb/engine}/parser/split_adapter.rb +0 -0
- data/lib/{exceptions → splitclient-rb/exceptions}/sdk_blocker_timeout_expired_exception.rb +0 -0
- data/lib/splitclient-rb/localhost_utils.rb +1 -1
- data/lib/splitclient-rb/split_config.rb +7 -4
- data/lib/splitclient-rb/utilitites.rb +41 -0
- data/lib/splitclient-rb/version.rb +1 -1
- data/splitclient-rb.gemspec +6 -8
- metadata +76 -100
- data/lib/engine/models/label.rb +0 -13
- data/lib/engine/partitions/treatments.rb +0 -36
- data/lib/splitclient-rb_utilitites.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81550066a81a8d86d50b4cea93346252fd3e19f6
|
4
|
+
data.tar.gz: 004ebf8003e161eef3712c4ba68350a732f113d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc9efa8080b148c9513ada659f842543ed1672e42cd64c1085c1c8a162e31553930509ca43e30a8b12a1ee9c5c434b5ac4347318bdd3cbb15e707071b45d368b
|
7
|
+
data.tar.gz: 43cfabd292ae2579e976508bc133894c697978f9cd03cc1c344ac1e48670f51b9cf77888e8db99ce1c8b3eb0f6b31061ddb577b550822d6a5905e74a194a6b23
|
data/CHANGES.txt
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
+
4.2.0 (July 18, 2017)
|
2
|
+
- Add new boolean/regexp matchers
|
3
|
+
- Add support for split dependency on other splits
|
4
|
+
- Pass bucketing_key to `match?` method
|
5
|
+
- Fix IP address fetching
|
6
|
+
- Remove unneeded dependencies (faraday_middleware, faraday-http-cache)
|
7
|
+
|
1
8
|
4.1.0 (April 16, 2017)
|
2
9
|
- Add new string/set matchers
|
10
|
+
- Use Rails logger if available. Now we do not pollute STDOUT by default
|
3
11
|
|
4
12
|
4.0.0
|
5
13
|
- Add support for murmur3 algo
|
data/NEWS
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
4.2.0
|
2
|
+
|
3
|
+
Introduce new matchers: boolean and regexp (string).
|
4
|
+
Remove unneeded dependencies
|
5
|
+
Introduce dependency matcher, which allows treatment of one split to depend on the evaluation of another.
|
6
|
+
|
1
7
|
4.1.0
|
2
8
|
|
3
9
|
Introduce set matchers: part of set, contains all and contains any, starts with, ends with and contains.
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ This SDK is designed to work with [Split](https://www.split.io), the platform fo
|
|
4
4
|
|
5
5
|
### Quick setup
|
6
6
|
|
7
|
-
For specific instructions on how to set up the
|
7
|
+
For specific instructions on how to set up the Split SDK refer to our [official SDK documentation](http://docs.split.io/docs/sdk-overview).
|
8
8
|
|
9
9
|
### Commitment to Quality:
|
10
10
|
|
@@ -12,21 +12,11 @@ Split’s SDKs are in active development and are constantly tested for quality.
|
|
12
12
|
|
13
13
|
### About Split:
|
14
14
|
|
15
|
-
Split
|
16
|
-
|
17
|
-
* What you can do with Split. Split goes beyond the simple on/off capabilities of basic feature flagging to give your team the power to:
|
18
|
-
|
19
|
-
* Create multivariate feature releases
|
20
|
-
* Create A/B feature releases
|
21
|
-
* Kill any feature, over the browser, with a single click
|
22
|
-
* Target releases to subsets of your audience, including percentage roll outs, whitelists, attribute-based targeting, and individual user IDs
|
23
|
-
* Integrate with the services your team uses to monitor, plan and communicate, like Datadog, JIRA and Slack
|
24
|
-
* Manage team access, with features like two-factor authentication and role-based permissioning.
|
25
|
-
|
15
|
+
Split is the leading platform for intelligent software delivery, helping businesses of all sizes deliver exceptional user experiences, and mitigate risk, by providing an easy, secure way to target features to customers. Companies like WePay, LendingTree and thredUP rely on Split to safely launch and test new features and derive insights on their use. Founded in 2015, Split's team comes from some of the most innovative enterprises in Silicon Valley, including Google, LinkedIn, Salesforce and Splunk. Split is based in Redwood City, California and backed by Accel Partners and Lightspeed Venture Partners. To learn more about Split, contact hello@split.io, or start a 14-day free trial at www.split.io/trial.
|
26
16
|
|
27
17
|
Split has built and maintains a SDKs for:
|
28
18
|
|
29
|
-
* Java [Docs](http://docs.split.io/docs/java-sdk-guide)
|
19
|
+
* Java [Github](https://github.com/splitio/java-client) [Docs](http://docs.split.io/docs/java-sdk-guide)
|
30
20
|
* Javascript [Github](https://github.com/splitio/javascript-client) [Docs](http://docs.split.io/docs/javascript-sdk-overview)
|
31
21
|
* Node [Github](https://github.com/splitio/javascript-client) [Docs](http://docs.split.io/docs/nodejs-sdk-overview)
|
32
22
|
* .NET [Github](https://github.com/splitio/.net-client) [Docs](http://docs.split.io/docs/net-sdk-overview)
|
@@ -34,11 +24,11 @@ Split has built and maintains a SDKs for:
|
|
34
24
|
* PHP [Github](https://github.com/splitio/php-client) [Docs](http://docs.split.io/docs/php-sdk-overview)
|
35
25
|
* Python [Github](https://github.com/splitio/python-client) [Docs](http://docs.split.io/docs/python-sdk-overview)
|
36
26
|
|
37
|
-
For a
|
27
|
+
For a comprehensive list of opensource projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).
|
38
28
|
|
39
29
|
**Try Split for Free:**
|
40
30
|
|
41
|
-
Split is available as a
|
31
|
+
Split is available as a 14-day free trial. To create an account, visit [split.io/trial](https://www.split.io/trial).
|
42
32
|
|
43
33
|
**Learn more about Split:**
|
44
34
|
|
@@ -47,6 +37,3 @@ Visit [split.io/product](https://www.split.io/product) for an overview of Split,
|
|
47
37
|
**System Status:**
|
48
38
|
|
49
39
|
We use a status page to monitor the availability of Split’s various services. You can check the current status at [status.split.io](http://status.split.io).
|
50
|
-
|
51
|
-
----
|
52
|
-
|
data/lib/splitclient-rb.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
require 'splitclient-rb/version'
|
2
2
|
|
3
|
-
require 'exceptions/sdk_blocker_timeout_expired_exception'
|
4
|
-
require 'cache/adapters/memory_adapters/map_adapter'
|
5
|
-
require 'cache/adapters/memory_adapters/queue_adapter'
|
6
|
-
require 'cache/adapters/memory_adapter'
|
7
|
-
require 'cache/adapters/redis_adapter'
|
8
|
-
require 'cache/repositories/repository'
|
9
|
-
require 'cache/repositories/segments_repository'
|
10
|
-
require 'cache/repositories/splits_repository'
|
11
|
-
require 'cache/repositories/impressions_repository'
|
12
|
-
require 'cache/repositories/impressions/memory_repository'
|
13
|
-
require 'cache/repositories/impressions/redis_repository'
|
14
|
-
require 'cache/repositories/metrics_repository'
|
15
|
-
require 'cache/repositories/metrics/memory_repository'
|
16
|
-
require 'cache/repositories/metrics/redis_repository'
|
17
|
-
require 'cache/senders/impressions_formatter'
|
18
|
-
require 'cache/senders/impressions_sender'
|
19
|
-
require 'cache/senders/metrics_sender'
|
20
|
-
require 'cache/stores/sdk_blocker'
|
21
|
-
require 'cache/stores/segment_store'
|
22
|
-
require 'cache/stores/split_store'
|
3
|
+
require 'splitclient-rb/exceptions/sdk_blocker_timeout_expired_exception'
|
4
|
+
require 'splitclient-rb/cache/adapters/memory_adapters/map_adapter'
|
5
|
+
require 'splitclient-rb/cache/adapters/memory_adapters/queue_adapter'
|
6
|
+
require 'splitclient-rb/cache/adapters/memory_adapter'
|
7
|
+
require 'splitclient-rb/cache/adapters/redis_adapter'
|
8
|
+
require 'splitclient-rb/cache/repositories/repository'
|
9
|
+
require 'splitclient-rb/cache/repositories/segments_repository'
|
10
|
+
require 'splitclient-rb/cache/repositories/splits_repository'
|
11
|
+
require 'splitclient-rb/cache/repositories/impressions_repository'
|
12
|
+
require 'splitclient-rb/cache/repositories/impressions/memory_repository'
|
13
|
+
require 'splitclient-rb/cache/repositories/impressions/redis_repository'
|
14
|
+
require 'splitclient-rb/cache/repositories/metrics_repository'
|
15
|
+
require 'splitclient-rb/cache/repositories/metrics/memory_repository'
|
16
|
+
require 'splitclient-rb/cache/repositories/metrics/redis_repository'
|
17
|
+
require 'splitclient-rb/cache/senders/impressions_formatter'
|
18
|
+
require 'splitclient-rb/cache/senders/impressions_sender'
|
19
|
+
require 'splitclient-rb/cache/senders/metrics_sender'
|
20
|
+
require 'splitclient-rb/cache/stores/sdk_blocker'
|
21
|
+
require 'splitclient-rb/cache/stores/segment_store'
|
22
|
+
require 'splitclient-rb/cache/stores/split_store'
|
23
23
|
|
24
24
|
require 'splitclient-rb/localhost_utils'
|
25
25
|
require 'splitclient-rb/clients/localhost_split_client'
|
@@ -31,37 +31,48 @@ require 'splitclient-rb/split_factory_builder'
|
|
31
31
|
require 'splitclient-rb/localhost_split_factory'
|
32
32
|
require 'splitclient-rb/split_config'
|
33
33
|
|
34
|
-
require 'engine/api/
|
35
|
-
require 'engine/api/
|
36
|
-
require 'engine/api/
|
37
|
-
require 'engine/api/
|
38
|
-
require 'engine/api/
|
39
|
-
require 'engine/
|
40
|
-
require 'engine/parser/
|
41
|
-
require 'engine/parser/
|
42
|
-
require 'engine/parser/
|
43
|
-
require 'engine/
|
44
|
-
require 'engine/matchers/combiners'
|
45
|
-
require 'engine/matchers/combining_matcher'
|
46
|
-
require 'engine/matchers/all_keys_matcher'
|
47
|
-
require 'engine/matchers/negation_matcher'
|
48
|
-
require 'engine/matchers/user_defined_segment_matcher'
|
49
|
-
require 'engine/matchers/whitelist_matcher'
|
50
|
-
require 'engine/matchers/equal_to_matcher'
|
51
|
-
require 'engine/matchers/greater_than_or_equal_to_matcher'
|
52
|
-
require 'engine/matchers/less_than_or_equal_to_matcher'
|
53
|
-
require 'engine/matchers/between_matcher'
|
54
|
-
require 'engine/matchers/set_matcher'
|
55
|
-
require 'engine/matchers/part_of_set_matcher'
|
56
|
-
require 'engine/matchers/equal_to_set_matcher'
|
57
|
-
require 'engine/matchers/contains_any_matcher'
|
58
|
-
require 'engine/matchers/contains_all_matcher'
|
59
|
-
require 'engine/matchers/starts_with_matcher'
|
60
|
-
require 'engine/matchers/ends_with_matcher'
|
61
|
-
require 'engine/matchers/contains_matcher'
|
62
|
-
require 'engine/
|
63
|
-
require 'engine/
|
64
|
-
require 'engine/
|
65
|
-
require 'engine/
|
66
|
-
require 'engine/
|
67
|
-
require 'splitclient-
|
34
|
+
require 'splitclient-rb/engine/api/faraday_middleware/gzip'
|
35
|
+
require 'splitclient-rb/engine/api/client'
|
36
|
+
require 'splitclient-rb/engine/api/impressions'
|
37
|
+
require 'splitclient-rb/engine/api/metrics'
|
38
|
+
require 'splitclient-rb/engine/api/segments'
|
39
|
+
require 'splitclient-rb/engine/api/splits'
|
40
|
+
require 'splitclient-rb/engine/parser/condition'
|
41
|
+
require 'splitclient-rb/engine/parser/partition'
|
42
|
+
require 'splitclient-rb/engine/parser/split_adapter'
|
43
|
+
require 'splitclient-rb/engine/parser/evaluator'
|
44
|
+
require 'splitclient-rb/engine/matchers/combiners'
|
45
|
+
require 'splitclient-rb/engine/matchers/combining_matcher'
|
46
|
+
require 'splitclient-rb/engine/matchers/all_keys_matcher'
|
47
|
+
require 'splitclient-rb/engine/matchers/negation_matcher'
|
48
|
+
require 'splitclient-rb/engine/matchers/user_defined_segment_matcher'
|
49
|
+
require 'splitclient-rb/engine/matchers/whitelist_matcher'
|
50
|
+
require 'splitclient-rb/engine/matchers/equal_to_matcher'
|
51
|
+
require 'splitclient-rb/engine/matchers/greater_than_or_equal_to_matcher'
|
52
|
+
require 'splitclient-rb/engine/matchers/less_than_or_equal_to_matcher'
|
53
|
+
require 'splitclient-rb/engine/matchers/between_matcher'
|
54
|
+
require 'splitclient-rb/engine/matchers/set_matcher'
|
55
|
+
require 'splitclient-rb/engine/matchers/part_of_set_matcher'
|
56
|
+
require 'splitclient-rb/engine/matchers/equal_to_set_matcher'
|
57
|
+
require 'splitclient-rb/engine/matchers/contains_any_matcher'
|
58
|
+
require 'splitclient-rb/engine/matchers/contains_all_matcher'
|
59
|
+
require 'splitclient-rb/engine/matchers/starts_with_matcher'
|
60
|
+
require 'splitclient-rb/engine/matchers/ends_with_matcher'
|
61
|
+
require 'splitclient-rb/engine/matchers/contains_matcher'
|
62
|
+
require 'splitclient-rb/engine/matchers/dependency_matcher'
|
63
|
+
require 'splitclient-rb/engine/matchers/equal_to_boolean_matcher'
|
64
|
+
require 'splitclient-rb/engine/matchers/equal_to_matcher'
|
65
|
+
require 'splitclient-rb/engine/matchers/matches_string_matcher'
|
66
|
+
require 'splitclient-rb/engine/evaluator/splitter'
|
67
|
+
require 'splitclient-rb/engine/metrics/metrics'
|
68
|
+
require 'splitclient-rb/engine/metrics/binary_search_latency_tracker'
|
69
|
+
require 'splitclient-rb/engine/models/split'
|
70
|
+
require 'splitclient-rb/engine/models/label'
|
71
|
+
require 'splitclient-rb/engine/models/treatment'
|
72
|
+
require 'splitclient-rb/utilitites'
|
73
|
+
|
74
|
+
module SplitIoClient
|
75
|
+
def self.root
|
76
|
+
File.dirname(__dir__)
|
77
|
+
end
|
78
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -44,12 +44,12 @@ module SplitIoClient
|
|
44
44
|
def get_treatment(id, feature, attributes = nil)
|
45
45
|
unless id
|
46
46
|
@config.logger.warn('id was null for feature: ' + feature)
|
47
|
-
return
|
47
|
+
return SplitIoClient::Engine::Models::Treatment::CONTROL
|
48
48
|
end
|
49
49
|
|
50
50
|
unless feature
|
51
51
|
@config.logger.warn('feature was null for id: ' + id)
|
52
|
-
return
|
52
|
+
return SplitIoClient::Engine::Models::Treatment::CONTROL
|
53
53
|
end
|
54
54
|
|
55
55
|
result = get_localhost_treatment(feature)
|
@@ -83,7 +83,7 @@ module SplitIoClient
|
|
83
83
|
def get_localhost_treatment(feature)
|
84
84
|
treatment = @localhost_mode_features.select { |h| h[:feature] == feature }.last || {}
|
85
85
|
|
86
|
-
treatment[:treatment] ||
|
86
|
+
treatment[:treatment] || SplitIoClient::Engine::Models::Treatment::CONTROL
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
@@ -19,14 +19,17 @@ module SplitIoClient
|
|
19
19
|
|
20
20
|
def get_treatments(key, split_names, attributes = nil)
|
21
21
|
bucketing_key, matching_key = keys_from_key(key)
|
22
|
+
evaluator = Engine::Parser::Evaluator.new(@segments_repository, @splits_repository, true)
|
22
23
|
|
23
24
|
treatments_labels_change_numbers =
|
24
25
|
@splits_repository.get_splits(split_names).each_with_object({}) do |(name, data), memo|
|
25
|
-
memo.merge!(name => get_treatment(key, name, attributes, data, false, true))
|
26
|
+
memo.merge!(name => get_treatment(key, name, attributes, data, false, true, evaluator))
|
26
27
|
end
|
27
28
|
|
28
29
|
if @config.impressions_queue_size > 0
|
29
|
-
@impressions_repository.add_bulk(
|
30
|
+
@impressions_repository.add_bulk(
|
31
|
+
matching_key, bucketing_key, treatments_labels_change_numbers, (Time.now.to_f * 1000.0).to_i
|
32
|
+
)
|
30
33
|
end
|
31
34
|
|
32
35
|
split_names = treatments_labels_change_numbers.keys
|
@@ -44,32 +47,38 @@ module SplitIoClient
|
|
44
47
|
# @param split_data [Hash] split data, when provided this method doesn't fetch splits_repository for the data
|
45
48
|
# @param store_impressions [Boolean] impressions aren't stored if this flag is false
|
46
49
|
# @param multiple [Hash] internal flag to signal if method is called by get_treatments
|
50
|
+
# @param evaluator [Evaluator] Evaluator class instance, used to cache treatments
|
47
51
|
#
|
48
52
|
# @return [String/Hash] Treatment as String or Hash of treatments in case of array of features
|
49
|
-
def get_treatment(
|
53
|
+
def get_treatment(
|
54
|
+
key, split_name, attributes = nil, split_data = nil, store_impressions = true,
|
55
|
+
multiple = false, evaluator = nil
|
56
|
+
)
|
50
57
|
bucketing_key, matching_key = keys_from_key(key)
|
58
|
+
treatment_data = { label: Engine::Models::Label::EXCEPTION, treatment: SplitIoClient::Engine::Models::Treatment::CONTROL }
|
59
|
+
evaluator ||= Engine::Parser::Evaluator.new(@segments_repository, @splits_repository)
|
51
60
|
|
52
61
|
if matching_key.nil?
|
53
62
|
@config.logger.warn('matching_key was null for split_name: ' + split_name.to_s)
|
54
|
-
return parsed_treatment(multiple,
|
63
|
+
return parsed_treatment(multiple, treatment_data)
|
55
64
|
end
|
56
65
|
|
57
66
|
if split_name.nil?
|
58
67
|
@config.logger.warn('split_name was null for key: ' + key)
|
59
|
-
return parsed_treatment(multiple,
|
68
|
+
return parsed_treatment(multiple, treatment_data)
|
60
69
|
end
|
61
70
|
|
62
71
|
start = Time.now
|
63
|
-
treatment_label_change_number = { label: Engine::Models::Label::EXCEPTION, treatment: Treatments::CONTROL }
|
64
72
|
|
65
73
|
begin
|
66
74
|
split = multiple ? split_data : @splits_repository.get_split(split_name)
|
67
75
|
|
68
76
|
if split.nil?
|
69
77
|
@config.logger.debug("split_name: #{split_name} does not exist. Returning CONTROL")
|
70
|
-
return parsed_treatment(multiple,
|
78
|
+
return parsed_treatment(multiple, treatment_data)
|
71
79
|
else
|
72
|
-
|
80
|
+
treatment_data =
|
81
|
+
evaluator.call(
|
73
82
|
{ bucketing_key: bucketing_key, matching_key: matching_key }, split, attributes
|
74
83
|
)
|
75
84
|
end
|
@@ -78,17 +87,17 @@ module SplitIoClient
|
|
78
87
|
|
79
88
|
store_impression(
|
80
89
|
split_name, matching_key, bucketing_key,
|
81
|
-
{ treatment: SplitIoClient::
|
90
|
+
{ treatment: SplitIoClient::Engine::Models::Treatment::CONTROL, label: Engine::Models::Label::EXCEPTION },
|
82
91
|
store_impressions
|
83
92
|
)
|
84
93
|
|
85
|
-
return parsed_treatment(multiple,
|
94
|
+
return parsed_treatment(multiple, treatment_data)
|
86
95
|
end
|
87
96
|
|
88
97
|
begin
|
89
98
|
latency = (Time.now - start) * 1000.0
|
90
99
|
# Disable impressions if @config.impressions_queue_size == -1
|
91
|
-
split && store_impression(split_name, matching_key, bucketing_key,
|
100
|
+
split && store_impression(split_name, matching_key, bucketing_key, treatment_data, store_impressions)
|
92
101
|
|
93
102
|
# Measure
|
94
103
|
@adapter.metrics.time('sdk.get_treatment', latency)
|
@@ -97,14 +106,14 @@ module SplitIoClient
|
|
97
106
|
|
98
107
|
store_impression(
|
99
108
|
split_name, matching_key, bucketing_key,
|
100
|
-
{ treatment: SplitIoClient::
|
109
|
+
{ treatment: SplitIoClient::Engine::Models::Treatment::CONTROL, label: Engine::Models::Label::EXCEPTION },
|
101
110
|
store_impressions
|
102
111
|
)
|
103
112
|
|
104
|
-
return parsed_treatment(multiple,
|
113
|
+
return parsed_treatment(multiple, treatment_data)
|
105
114
|
end
|
106
115
|
|
107
|
-
parsed_treatment(multiple,
|
116
|
+
parsed_treatment(multiple, treatment_data)
|
108
117
|
end
|
109
118
|
|
110
119
|
def store_impression(split_name, matching_key, bucketing_key, treatment, store_impressions)
|
@@ -129,22 +138,16 @@ module SplitIoClient
|
|
129
138
|
end
|
130
139
|
end
|
131
140
|
|
132
|
-
def parsed_treatment(multiple,
|
141
|
+
def parsed_treatment(multiple, treatment_data)
|
133
142
|
if multiple
|
134
143
|
{
|
135
|
-
treatment:
|
136
|
-
label:
|
137
|
-
change_number:
|
144
|
+
treatment: treatment_data[:treatment],
|
145
|
+
label: treatment_data[:label],
|
146
|
+
change_number: treatment_data[:change_number]
|
138
147
|
}
|
139
148
|
else
|
140
|
-
|
149
|
+
treatment_data[:treatment]
|
141
150
|
end
|
142
151
|
end
|
143
|
-
|
144
|
-
private
|
145
|
-
|
146
|
-
def split_treatment
|
147
|
-
@split_treatment ||= SplitIoClient::Engine::Parser::SplitTreatment.new(@segments_repository)
|
148
|
-
end
|
149
152
|
end
|
150
153
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
require 'bundler/vendor/net/http/persistent' unless defined?(Net::HTTP)
|
3
|
-
require 'faraday_middleware'
|
1
|
+
require 'net/http/persistent'
|
4
2
|
|
5
3
|
module SplitIoClient
|
6
4
|
module Api
|
7
5
|
class Client
|
6
|
+
RUBY_ENCODING = '1.9'.respond_to?(:force_encoding)
|
7
|
+
|
8
8
|
def get_api(url, config, api_key, params = {})
|
9
9
|
api_client.get(url, params) do |req|
|
10
10
|
req.headers = common_headers(api_key, config).merge('Accept-Encoding' => 'gzip')
|
@@ -47,7 +47,7 @@ module SplitIoClient
|
|
47
47
|
|
48
48
|
def api_client
|
49
49
|
@api_client ||= Faraday.new do |builder|
|
50
|
-
builder.use FaradayMiddleware::Gzip
|
50
|
+
builder.use SplitIoClient::FaradayMiddleware::Gzip
|
51
51
|
builder.adapter :net_http_persistent
|
52
52
|
end
|
53
53
|
end
|