splitclient-rb 1.0.0 → 1.0.1
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 +5 -0
- data/NEWS +6 -0
- data/lib/splitclient-rb/split_client.rb +27 -41
- data/lib/splitclient-rb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d21886d355095f95e8b513b0769afe03e89b532c
|
4
|
+
data.tar.gz: ac174313940a5ab346c6e56235ce7e2c24f8df61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50a14d46b118a08adfcac8cb56844c5baf7c79ca90bab323bf9b6103b37221bfde29779c3ca44d5c931a9ffac43e6731a12ca2e3060981c7ce5f072e326a0e8e
|
7
|
+
data.tar.gz: b63d863d0b8dab1e4dfdea1bffb9d085bf39357f3d679a94c595b9474be7fe93f325c04d3e2abff82ddf78d88faa50a536d15d688ecec60a18150a540e6dd57d
|
data/CHANGES.txt
CHANGED
data/NEWS
CHANGED
@@ -40,29 +40,6 @@ module SplitIoClient
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
#
|
44
|
-
# validates the treatment for the provided user key and feature
|
45
|
-
#
|
46
|
-
# @param id [string] user id
|
47
|
-
# @param feature [string] name of the feature that is being validated
|
48
|
-
# @param treatment [string] value of the treatment for this user key and feature
|
49
|
-
#
|
50
|
-
# @return [boolean] true if the user key has valida treatment, false otherwise
|
51
|
-
def is_treatment?(id, feature, treatment)
|
52
|
-
is_treatment = false
|
53
|
-
|
54
|
-
if is_localhost_mode?
|
55
|
-
is_treatment = get_localhost_treatment(feature)
|
56
|
-
else
|
57
|
-
begin
|
58
|
-
is_treatment = (get_treatment(id, feature) == treatment)
|
59
|
-
rescue
|
60
|
-
@config.logger.error("MUST NOT throw this error")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
is_treatment
|
64
|
-
end
|
65
|
-
|
66
43
|
#
|
67
44
|
# obtains the treatment for a given feature
|
68
45
|
#
|
@@ -81,25 +58,30 @@ module SplitIoClient
|
|
81
58
|
return Treatments::CONTROL
|
82
59
|
end
|
83
60
|
|
84
|
-
|
85
|
-
|
61
|
+
if is_localhost_mode?
|
62
|
+
result = get_localhost_treatment(feature)
|
63
|
+
else
|
64
|
+
start = Time.now
|
65
|
+
result = nil
|
86
66
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
67
|
+
begin
|
68
|
+
result = get_treatment_without_exception_handling(id, feature)
|
69
|
+
rescue StandardError => error
|
70
|
+
@config.log_found_exception(__method__.to_s, error)
|
71
|
+
end
|
92
72
|
|
93
|
-
|
73
|
+
result = result.nil? ? Treatments::CONTROL : result
|
94
74
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
75
|
+
begin
|
76
|
+
@adapter.impressions.log(id, feature, result, (Time.now.to_f * 1000.0))
|
77
|
+
latency = (Time.now - start) * 1000.0
|
78
|
+
if (@adapter.impressions.queue.length >= @adapter.impressions.max_number_of_keys)
|
79
|
+
@adapter.impressions_producer.wakeup
|
80
|
+
end
|
81
|
+
rescue StandardError => error
|
82
|
+
@config.log_found_exception(__method__.to_s, error)
|
100
83
|
end
|
101
|
-
|
102
|
-
@config.log_found_exception(__method__.to_s, error)
|
84
|
+
|
103
85
|
end
|
104
86
|
|
105
87
|
result
|
@@ -145,11 +127,12 @@ module SplitIoClient
|
|
145
127
|
#
|
146
128
|
# @returns [void]
|
147
129
|
def load_localhost_mode_features
|
148
|
-
splits_file = File.join(Dir.home, ".
|
130
|
+
splits_file = File.join(Dir.home, ".split")
|
149
131
|
if File.exists?(splits_file)
|
150
132
|
line_num=0
|
151
133
|
File.open(splits_file).each do |line|
|
152
|
-
|
134
|
+
line_data = line.strip.split(" ")
|
135
|
+
@localhost_mode_features << {feature: line_data[0], treatment: line_data[1]} unless line.start_with?('#') || line.strip.empty?
|
153
136
|
end
|
154
137
|
end
|
155
138
|
end
|
@@ -159,7 +142,10 @@ module SplitIoClient
|
|
159
142
|
#
|
160
143
|
# @return [boolean] true if the feature is available in localhost mode, false otherwise
|
161
144
|
def get_localhost_treatment(feature)
|
162
|
-
|
145
|
+
localhost_result = Treatments::CONTROL
|
146
|
+
treatment = @localhost_mode_features.select{|h| h[:feature] == feature}.last
|
147
|
+
localhost_result = treatment[:treatment] if !treatment.nil?
|
148
|
+
localhost_result
|
163
149
|
end
|
164
150
|
|
165
151
|
private :get_treatment_without_exception_handling, :is_localhost_mode?,
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Split Software
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|