amplitude-experiment 1.1.3 → 1.1.5
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4c7cef3c90843aec26f85cc3706300eb1f6bff3f64c1db9b4162bdf20dc1119
|
4
|
+
data.tar.gz: bd937b2d414b7b52b3accf57de14ac556a1789f83dd1e5d1625727ae5c9a0222
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c927c9bc9808738b641cdf6666e7fa3220dad2d68b275d2d9b4269ebedf5ade2cd421a4e7c77a4283d8c0c0cfd9be2579d209ac9e4430b989dcf6dd864b98b4b
|
7
|
+
data.tar.gz: b388bc2f602af8031e5fb01cdd862ea31149a142d0fcf559703cdb2a76554cc051a339be8e8670862a129669a09535342ed3a766411c931c9a1c1ec019dbd082
|
@@ -64,7 +64,7 @@ module AmplitudeExperiment
|
|
64
64
|
def parse_results(result, flag_keys)
|
65
65
|
variants = {}
|
66
66
|
result.each do |key, value|
|
67
|
-
next if value['isDefaultVariant'] || (flag_keys.empty? && flag_keys.include?(key))
|
67
|
+
next if value['isDefaultVariant'] || (!flag_keys.empty? && !flag_keys.include?(key))
|
68
68
|
|
69
69
|
variant_key = value['variant']['key']
|
70
70
|
variant_payload = value['variant']['payload']
|
@@ -9,7 +9,7 @@ module AmplitudeExperiment
|
|
9
9
|
@api_key = api_key
|
10
10
|
@server_url = server_url
|
11
11
|
@logger = logger
|
12
|
-
@http = PersistentHttpClient.get(server_url, { read_timeout: FLAG_CONFIG_TIMEOUT })
|
12
|
+
@http = PersistentHttpClient.get(server_url, { read_timeout: FLAG_CONFIG_TIMEOUT }, @api_key)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Fetch local evaluation mode flag configs from the Experiment API server.
|
@@ -1,14 +1,20 @@
|
|
1
1
|
module AmplitudeExperiment
|
2
|
-
# Persist Http Client to reuse connection and reduce IO
|
2
|
+
# Persist Http Client to reuse connection and reduce IO. Connections are
|
3
|
+
# shared by api key.
|
4
|
+
#
|
5
|
+
# WARNING: these connections are not safe for concurrent requests. Callers
|
6
|
+
# must synchronize requests per connection.
|
3
7
|
class PersistentHttpClient
|
4
8
|
DEFAULT_OPTIONS = { read_timeout: 80 }.freeze
|
5
9
|
|
6
10
|
class << self
|
7
11
|
# url: URI / String
|
8
12
|
# options: any options that Net::HTTP.new accepts
|
9
|
-
|
13
|
+
# api_key: the deployment key for ensuring different deployments don't
|
14
|
+
# share connections.
|
15
|
+
def get(url, options, api_key)
|
10
16
|
uri = url.is_a?(URI) ? url : URI(url)
|
11
|
-
connection_manager.get_client(uri, options)
|
17
|
+
connection_manager.get_client(uri, options, api_key)
|
12
18
|
end
|
13
19
|
|
14
20
|
private
|
@@ -72,7 +78,7 @@ module AmplitudeExperiment
|
|
72
78
|
self.last_used = Time.now
|
73
79
|
end
|
74
80
|
|
75
|
-
def get_client(uri, options)
|
81
|
+
def get_client(uri, options, api_key)
|
76
82
|
mutex.synchronize do
|
77
83
|
# refresh the last time a client was used,
|
78
84
|
# this prevents the client from becoming stale
|
@@ -81,7 +87,7 @@ module AmplitudeExperiment
|
|
81
87
|
# we use params as a cache key for clients.
|
82
88
|
# 2 connections to the same host but with different
|
83
89
|
# options are going to use different HTTP clients
|
84
|
-
params = [uri.host, uri.port, options]
|
90
|
+
params = [uri.host, uri.port, options, api_key]
|
85
91
|
client = clients_store[params]
|
86
92
|
|
87
93
|
return client if client
|
@@ -99,7 +99,7 @@ module AmplitudeExperiment
|
|
99
99
|
'Content-Type' => 'application/json;charset=utf-8'
|
100
100
|
}
|
101
101
|
read_timeout = timeout_millis / 1000 if (timeout_millis / 1000) > 0
|
102
|
-
http = PersistentHttpClient.get(@uri, { read_timeout: read_timeout })
|
102
|
+
http = PersistentHttpClient.get(@uri, { read_timeout: read_timeout }, @api_key)
|
103
103
|
request = Net::HTTP::Post.new(@uri, headers)
|
104
104
|
request.body = user_context.to_json
|
105
105
|
if request.body.length > 8000
|
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.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amplitude
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: psych
|