splitclient-rb 3.2.4 → 3.3.0.pre.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.txt +3 -0
- data/NEWS +4 -0
- data/lib/engine/models/label.rb +5 -4
- data/lib/engine/parser/condition.rb +8 -0
- data/lib/engine/parser/partition.rb +2 -4
- data/lib/engine/parser/split_treatment.rb +15 -1
- data/lib/splitclient-rb/clients/split_client.rb +27 -11
- data/lib/splitclient-rb/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8341508fbe2e85f51f48b68830a173dff7f8b87f
|
4
|
+
data.tar.gz: 6d199d8c2369cd469aba09869614009a38d6723a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00372ba9e41399940663fc1ef0a8bb0128f5a1cc4dd0e178c619cf83c57446eb025983f7973b278e18b96e2abf15421aa5ffb056445a78584c50df07d290116e
|
7
|
+
data.tar.gz: 110fce581be2047a48453e336e26bb0125fb2f5753b5cab70fb313f522d061fa1599375887313162778266ad2562fa5d602e4b3b97ac8115fd73e365b29c3863
|
data/CHANGES.txt
CHANGED
data/NEWS
CHANGED
data/lib/engine/models/label.rb
CHANGED
@@ -2,10 +2,11 @@ module SplitIoClient
|
|
2
2
|
module Engine
|
3
3
|
module Models
|
4
4
|
class Label
|
5
|
-
ARCHIVED = 'archived'
|
6
|
-
NO_RULE_MATCHED = 'no rule matched'
|
7
|
-
EXCEPTION = 'exception'
|
8
|
-
KILLED = 'killed'
|
5
|
+
ARCHIVED = 'archived'.freeze
|
6
|
+
NO_RULE_MATCHED = 'no rule matched'.freeze
|
7
|
+
EXCEPTION = 'exception'.freeze
|
8
|
+
KILLED = 'killed'.freeze
|
9
|
+
NOT_IN_SPLIT = 'not in split'.freeze
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -3,6 +3,8 @@ module SplitIoClient
|
|
3
3
|
# acts as dto for a condition structure
|
4
4
|
#
|
5
5
|
class Condition < NoMethodError
|
6
|
+
TYPE_ROLLOUT = 'ROLLOUT'.freeze
|
7
|
+
TYPE_WHITELIST = 'WHITELIST'.freeze
|
6
8
|
#
|
7
9
|
# definition of the condition
|
8
10
|
#
|
@@ -36,6 +38,12 @@ module SplitIoClient
|
|
36
38
|
@data[:matcherGroup][:matchers]
|
37
39
|
end
|
38
40
|
|
41
|
+
#
|
42
|
+
# @return [string] condition type
|
43
|
+
def type
|
44
|
+
@data[:conditionType]
|
45
|
+
end
|
46
|
+
|
39
47
|
def negation_matcher(matcher)
|
40
48
|
NegationMatcher.new(matcher)
|
41
49
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
module SplitIoClient
|
2
|
-
|
3
2
|
#
|
4
3
|
# acts as dto for a partition structure
|
5
4
|
#
|
@@ -30,8 +29,7 @@ module SplitIoClient
|
|
30
29
|
#
|
31
30
|
# @return [boolean] true if the partition is empty false otherwise
|
32
31
|
def is_empty?
|
33
|
-
@data.empty?
|
32
|
+
@data.empty?
|
34
33
|
end
|
35
34
|
end
|
36
|
-
|
37
|
-
end
|
35
|
+
end
|
@@ -21,13 +21,27 @@ module SplitIoClient
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def match(split, keys, attributes)
|
24
|
+
in_rollout = false
|
25
|
+
key = keys[:bucketing_key] ? keys[:bucketing_key] : keys[:matching_key]
|
26
|
+
|
24
27
|
split[:conditions].each do |c|
|
25
28
|
condition = SplitIoClient::Condition.new(c)
|
26
29
|
|
27
30
|
next if condition.empty?
|
28
31
|
|
32
|
+
if !in_rollout && condition.type == SplitIoClient::Condition::TYPE_ROLLOUT
|
33
|
+
if split[:trafficAllocation] < 100
|
34
|
+
bucket = Splitter.bucket(Splitter.hash(key, split[:trafficAllocationSeed].to_i))
|
35
|
+
|
36
|
+
if bucket >= split[:trafficAllocation]
|
37
|
+
return treatment(Models::Label::NOT_IN_SPLIT, @default_treatment, split[:changeNumber])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
in_rollout = true
|
42
|
+
end
|
43
|
+
|
29
44
|
if matcher_type(condition).match?(keys[:matching_key], attributes)
|
30
|
-
key = keys[:bucketing_key] ? keys[:bucketing_key] : keys[:matching_key]
|
31
45
|
result = Splitter.get_treatment(key, split[:seed], condition.partitions)
|
32
46
|
|
33
47
|
if result.nil?
|
@@ -77,34 +77,50 @@ module SplitIoClient
|
|
77
77
|
rescue StandardError => error
|
78
78
|
@config.log_found_exception(__method__.to_s, error)
|
79
79
|
|
80
|
+
store_impression(
|
81
|
+
split_name, matching_key, bucketing_key,
|
82
|
+
{ treatment: SplitIoClient::Treatments::CONTROL, label: Models::Label::EXCEPTION },
|
83
|
+
store_impressions
|
84
|
+
)
|
85
|
+
|
80
86
|
return parsed_treatment(multiple, treatment_label_change_number)
|
81
87
|
end
|
82
88
|
|
83
89
|
begin
|
84
90
|
latency = (Time.now - start) * 1000.0
|
85
|
-
if @config.impressions_queue_size
|
86
|
-
|
87
|
-
@impressions_repository.add(split_name,
|
88
|
-
'keyName' => matching_key,
|
89
|
-
'bucketingKey' => bucketing_key,
|
90
|
-
'treatment' => treatment_label_change_number[:treatment],
|
91
|
-
'label' => @config.labels_enabled ? treatment_label_change_number[:label] : nil,
|
92
|
-
'time' => (Time.now.to_f * 1000.0).to_i,
|
93
|
-
'changeNumber' => treatment_label_change_number[:change_number]
|
94
|
-
)
|
95
|
-
end
|
91
|
+
# Disable impressions if @config.impressions_queue_size == -1
|
92
|
+
split && store_impression(split_name, matching_key, bucketing_key, treatment_label_change_number, store_impressions)
|
96
93
|
|
97
94
|
# Measure
|
98
95
|
@adapter.metrics.time('sdk.get_treatment', latency)
|
99
96
|
rescue StandardError => error
|
100
97
|
@config.log_found_exception(__method__.to_s, error)
|
101
98
|
|
99
|
+
store_impression(
|
100
|
+
split_name, matching_key, bucketing_key,
|
101
|
+
{ treatment: SplitIoClient::Treatments::CONTROL, label: Models::Label::EXCEPTION },
|
102
|
+
store_impressions
|
103
|
+
)
|
104
|
+
|
102
105
|
return parsed_treatment(multiple, treatment_label_change_number)
|
103
106
|
end
|
104
107
|
|
105
108
|
parsed_treatment(multiple, treatment_label_change_number)
|
106
109
|
end
|
107
110
|
|
111
|
+
def store_impression(split_name, matching_key, bucketing_key, treatment, store_impressions)
|
112
|
+
return if @config.impressions_queue_size <= 0 || !store_impressions
|
113
|
+
|
114
|
+
@impressions_repository.add(split_name,
|
115
|
+
'keyName' => matching_key,
|
116
|
+
'bucketingKey' => bucketing_key,
|
117
|
+
'treatment' => treatment[:treatment],
|
118
|
+
'label' => @config.labels_enabled ? treatment[:label] : nil,
|
119
|
+
'time' => (Time.now.to_f * 1000.0).to_i,
|
120
|
+
'changeNumber' => treatment[:change_number]
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
108
124
|
def keys_from_key(key)
|
109
125
|
case key.class.to_s
|
110
126
|
when 'Hash'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: splitclient-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0.pre.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Split Software
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -330,9 +330,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
330
330
|
version: '0'
|
331
331
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
332
332
|
requirements:
|
333
|
-
- - "
|
333
|
+
- - ">"
|
334
334
|
- !ruby/object:Gem::Version
|
335
|
-
version:
|
335
|
+
version: 1.3.1
|
336
336
|
requirements: []
|
337
337
|
rubyforge_project:
|
338
338
|
rubygems_version: 2.5.2
|