amplitude-experiment 1.0.0.beta.10 → 1.0.0.beta.12
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1d0e0df050662d2ad81e129d2e4ab162d7555c63546124216f716977828f982
|
4
|
+
data.tar.gz: 64afa393e382f42bbb4d11d170479bef43c74f02a3eaa43c18a380411fac2628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfeb1ffdfb5bddcd145153fecfcf0aeb0b89057cd89e2055e52d8b7da739a79f3ab200015603dd85cc050f94e061141ffe8cfa9057a67a25f41b4042e7646b23
|
7
|
+
data.tar.gz: 86a6e401ebf724eb1bf082117da9c9b5cfe4baf7835ccdeba811a1ab3feb38772e49bacecbb3fd9b801227b1c1cd604c196d9e56dd282c1cbe455a283e32b3b5
|
@@ -20,7 +20,7 @@ module AmplitudeExperiment
|
|
20
20
|
Logger::INFO
|
21
21
|
end
|
22
22
|
@fetcher = LocalEvaluationFetcher.new(api_key, @config.debug, @config.server_url)
|
23
|
-
@poller = FlagConfigPoller.new(@fetcher, @cache, @config.debug)
|
23
|
+
@poller = FlagConfigPoller.new(@fetcher, @cache, @config.debug, @config.flag_config_polling_interval_millis)
|
24
24
|
|
25
25
|
raise ArgumentError, 'Experiment API key is empty' if @api_key.nil? || @api_key.empty?
|
26
26
|
end
|
@@ -44,7 +44,7 @@ module AmplitudeExperiment
|
|
44
44
|
user_str = user.to_json
|
45
45
|
@logger.debug("[Experiment] Evaluate: User: #{user_str} - Rules: #{flag_configs_str}") if @config.debug
|
46
46
|
result_json = evaluation(flag_configs_str, user_str)
|
47
|
-
@logger.debug(
|
47
|
+
@logger.debug("[Experiment] evaluate - result: #{variants}") if @config.debug
|
48
48
|
result = JSON.parse(result_json)
|
49
49
|
variants = {}
|
50
50
|
result.each do |key, value|
|
@@ -24,8 +24,8 @@ module AmplitudeExperiment
|
|
24
24
|
# @param [String] server_url The server endpoint from which to request variants.
|
25
25
|
# @param [Hash] bootstrap The value of bootstrap.
|
26
26
|
# @param [long] flag_config_polling_interval_millis The value of flag config polling interval in million seconds.
|
27
|
-
def initialize(server_url
|
28
|
-
flag_config_polling_interval_millis
|
27
|
+
def initialize(server_url: DEFAULT_SERVER_URL, bootstrap: {},
|
28
|
+
flag_config_polling_interval_millis: 30_000, debug: false)
|
29
29
|
@debug = debug || false
|
30
30
|
@server_url = server_url
|
31
31
|
@bootstrap = bootstrap
|
@@ -25,7 +25,7 @@ module AmplitudeExperiment
|
|
25
25
|
}
|
26
26
|
request = Net::HTTP::Get.new(@uri, headers)
|
27
27
|
response = @http.request(request)
|
28
|
-
raise
|
28
|
+
raise "flagConfigs - received error response: #{response.code}: #{response.body}" unless response.is_a?(Net::HTTPOK)
|
29
29
|
|
30
30
|
flag_configs = parse(response.body)
|
31
31
|
@logger.debug("[Experiment] Fetch flag configs: #{request.body}") if @debug
|
@@ -4,7 +4,7 @@ module AmplitudeExperiment
|
|
4
4
|
class FlagConfigPoller
|
5
5
|
FLAG_CONFIG_POLLING_INTERVAL_MILLIS = 30_000
|
6
6
|
|
7
|
-
def initialize(fetcher, cache, debug, poll_interval_millis
|
7
|
+
def initialize(fetcher, cache, debug, poll_interval_millis = FLAG_CONFIG_POLLING_INTERVAL_MILLIS)
|
8
8
|
@fetcher = fetcher
|
9
9
|
@cache = cache
|
10
10
|
@poll_interval_millis = poll_interval_millis
|
@@ -40,7 +40,7 @@ module AmplitudeExperiment
|
|
40
40
|
@cache.clear
|
41
41
|
@cache.put_all(flag_configs)
|
42
42
|
@poller_thread = Thread.new do
|
43
|
-
sleep
|
43
|
+
sleep(@poll_interval_millis / 1000.to_f)
|
44
44
|
run
|
45
45
|
end
|
46
46
|
end
|
data/lib/experiment/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amplitude-experiment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.beta.
|
4
|
+
version: 1.0.0.beta.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amplitude
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|