configcat 2.0.5 → 3.0.0
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/lib/configcat.rb +18 -18
- data/lib/configcat/autopollingcachepolicy.rb +1 -1
- data/lib/configcat/configcatclient.rb +7 -7
- data/lib/configcat/configfetcher.rb +3 -3
- data/lib/configcat/lazyloadingcachepolicy.rb +1 -1
- data/lib/configcat/manualpollingcachepolicy.rb +1 -1
- data/lib/configcat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed70c40f6865601f6d5476cbb12b158e359413baa9fc186a58c0bc0b1334e9a5
|
4
|
+
data.tar.gz: 848a6b3550eee7cdc6cb0467b0b0893e6f37ce9d1a0dffb95c77ca4f248e8d74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aa50e9733ab9ed0612d28fe2daee49ce0396feb1fab353324b2d3ae63ce67722a58d7c0c67d5884d4146106bd52859e36e08725a1a1757390bb6462baf4c1e0
|
7
|
+
data.tar.gz: 40a2aa9993dc5ba3cba64c944a06c9c4c15895ba4ee6f227db250abe051894956f7c3fc2fe7dff298582ce4e573190e5cc8d4e0055afcdff0e5ed278f7d2a52e
|
data/lib/configcat.rb
CHANGED
@@ -10,16 +10,16 @@ module ConfigCat
|
|
10
10
|
attr_accessor :logger
|
11
11
|
end
|
12
12
|
|
13
|
-
def ConfigCat.create_client(
|
13
|
+
def ConfigCat.create_client(sdk_key)
|
14
14
|
#
|
15
15
|
# Create an instance of ConfigCatClient and setup Auto Poll mode with default options
|
16
16
|
#
|
17
|
-
# :param
|
17
|
+
# :param sdk_key: ConfigCat SDK Key to access your configuration.
|
18
18
|
#
|
19
|
-
return create_client_with_auto_poll(
|
19
|
+
return create_client_with_auto_poll(sdk_key)
|
20
20
|
end
|
21
21
|
|
22
|
-
def ConfigCat.create_client_with_auto_poll(
|
22
|
+
def ConfigCat.create_client_with_auto_poll(sdk_key,
|
23
23
|
poll_interval_seconds: 60,
|
24
24
|
max_init_wait_time_seconds: 5,
|
25
25
|
on_configuration_changed_callback: nil,
|
@@ -32,7 +32,7 @@ module ConfigCat
|
|
32
32
|
#
|
33
33
|
# Create an instance of ConfigCatClient and setup Auto Poll mode with custom options
|
34
34
|
#
|
35
|
-
# :param
|
35
|
+
# :param sdk_key: ConfigCat SDK Key to access your configuration.
|
36
36
|
# :param poll_interval_seconds: The client's poll interval in seconds. Default: 60 seconds.
|
37
37
|
# :param on_configuration_changed_callback: You can subscribe to configuration changes with this callback
|
38
38
|
# :param max_init_wait_time_seconds: maximum waiting time for first configuration fetch in polling mode.
|
@@ -44,8 +44,8 @@ module ConfigCat
|
|
44
44
|
# :param proxy_user: username for proxy authentication
|
45
45
|
# :param proxy_pass: password for proxy authentication
|
46
46
|
#
|
47
|
-
if
|
48
|
-
raise ConfigCatClientException, "
|
47
|
+
if sdk_key === nil
|
48
|
+
raise ConfigCatClientException, "SDK Key is required."
|
49
49
|
end
|
50
50
|
if poll_interval_seconds < 1
|
51
51
|
poll_interval_seconds = 1
|
@@ -53,7 +53,7 @@ module ConfigCat
|
|
53
53
|
if max_init_wait_time_seconds < 0
|
54
54
|
max_init_wait_time_seconds = 0
|
55
55
|
end
|
56
|
-
return ConfigCatClient.new(
|
56
|
+
return ConfigCatClient.new(sdk_key,
|
57
57
|
poll_interval_seconds: poll_interval_seconds,
|
58
58
|
max_init_wait_time_seconds: max_init_wait_time_seconds,
|
59
59
|
on_configuration_changed_callback: on_configuration_changed_callback,
|
@@ -66,7 +66,7 @@ module ConfigCat
|
|
66
66
|
proxy_pass: proxy_pass)
|
67
67
|
end
|
68
68
|
|
69
|
-
def ConfigCat.create_client_with_lazy_load(
|
69
|
+
def ConfigCat.create_client_with_lazy_load(sdk_key,
|
70
70
|
cache_time_to_live_seconds: 60,
|
71
71
|
config_cache_class: nil,
|
72
72
|
base_url: nil,
|
@@ -77,7 +77,7 @@ module ConfigCat
|
|
77
77
|
#
|
78
78
|
# Create an instance of ConfigCatClient and setup Lazy Load mode with custom options
|
79
79
|
#
|
80
|
-
# :param
|
80
|
+
# :param sdk_key: ConfigCat SDK Key to access your configuration.
|
81
81
|
# :param cache_time_to_live_seconds: The cache TTL.
|
82
82
|
# :param config_cache_class: If you want to use custom caching instead of the client's default InMemoryConfigCache,
|
83
83
|
# You can provide an implementation of ConfigCache.
|
@@ -87,13 +87,13 @@ module ConfigCat
|
|
87
87
|
# :param proxy_user: username for proxy authentication
|
88
88
|
# :param proxy_pass: password for proxy authentication
|
89
89
|
#
|
90
|
-
if
|
91
|
-
raise ConfigCatClientException, "
|
90
|
+
if sdk_key === nil
|
91
|
+
raise ConfigCatClientException, "SDK Key is required."
|
92
92
|
end
|
93
93
|
if cache_time_to_live_seconds < 1
|
94
94
|
cache_time_to_live_seconds = 1
|
95
95
|
end
|
96
|
-
return ConfigCatClient.new(
|
96
|
+
return ConfigCatClient.new(sdk_key,
|
97
97
|
poll_interval_seconds: 0,
|
98
98
|
max_init_wait_time_seconds: 0,
|
99
99
|
on_configuration_changed_callback: nil,
|
@@ -106,7 +106,7 @@ module ConfigCat
|
|
106
106
|
proxy_pass: proxy_pass)
|
107
107
|
end
|
108
108
|
|
109
|
-
def ConfigCat.create_client_with_manual_poll(
|
109
|
+
def ConfigCat.create_client_with_manual_poll(sdk_key,
|
110
110
|
config_cache_class: nil,
|
111
111
|
base_url: nil,
|
112
112
|
proxy_address:nil,
|
@@ -116,7 +116,7 @@ module ConfigCat
|
|
116
116
|
#
|
117
117
|
# Create an instance of ConfigCatClient and setup Manual Poll mode with custom options
|
118
118
|
#
|
119
|
-
# :param
|
119
|
+
# :param sdk_key: ConfigCat SDK Key to access your configuration.
|
120
120
|
# :param config_cache_class: If you want to use custom caching instead of the client's default InMemoryConfigCache,
|
121
121
|
# You can provide an implementation of ConfigCache.
|
122
122
|
# :param base_url: You can set a base_url if you want to use a proxy server between your application and ConfigCat
|
@@ -125,10 +125,10 @@ module ConfigCat
|
|
125
125
|
# :param proxy_user: username for proxy authentication
|
126
126
|
# :param proxy_pass: password for proxy authentication
|
127
127
|
#
|
128
|
-
if
|
129
|
-
raise ConfigCatClientException, "
|
128
|
+
if sdk_key === nil
|
129
|
+
raise ConfigCatClientException, "SDK Key is required."
|
130
130
|
end
|
131
|
-
return ConfigCatClient.new(
|
131
|
+
return ConfigCatClient.new(sdk_key,
|
132
132
|
poll_interval_seconds: 0,
|
133
133
|
max_init_wait_time_seconds: 0,
|
134
134
|
on_configuration_changed_callback: nil,
|
@@ -81,7 +81,7 @@ module ConfigCat
|
|
81
81
|
@_initialized = true
|
82
82
|
end
|
83
83
|
rescue Exception => e
|
84
|
-
ConfigCat.logger.error("Double-check your
|
84
|
+
ConfigCat.logger.error("Double-check your SDK Key at https://app.configcat.com/sdkkey.")
|
85
85
|
ConfigCat.logger.error "threw exception #{e.class}:'#{e}'"
|
86
86
|
ConfigCat.logger.error "stacktrace: #{e.backtrace}"
|
87
87
|
end
|
@@ -8,7 +8,7 @@ require 'configcat/rolloutevaluator'
|
|
8
8
|
|
9
9
|
module ConfigCat
|
10
10
|
class ConfigCatClient
|
11
|
-
def initialize(
|
11
|
+
def initialize(sdk_key,
|
12
12
|
poll_interval_seconds:60,
|
13
13
|
max_init_wait_time_seconds:5,
|
14
14
|
on_configuration_changed_callback:nil,
|
@@ -19,10 +19,10 @@ module ConfigCat
|
|
19
19
|
proxy_port:nil,
|
20
20
|
proxy_user:nil,
|
21
21
|
proxy_pass:nil)
|
22
|
-
if
|
23
|
-
raise ConfigCatClientException, "
|
22
|
+
if sdk_key === nil
|
23
|
+
raise ConfigCatClientException, "SDK Key is required."
|
24
24
|
end
|
25
|
-
@
|
25
|
+
@_sdk_key = sdk_key
|
26
26
|
|
27
27
|
if config_cache_class
|
28
28
|
@_config_cache = config_cache_class.new()
|
@@ -31,14 +31,14 @@ module ConfigCat
|
|
31
31
|
end
|
32
32
|
|
33
33
|
if poll_interval_seconds > 0
|
34
|
-
@_config_fetcher = CacheControlConfigFetcher.new(
|
34
|
+
@_config_fetcher = CacheControlConfigFetcher.new(sdk_key, "p", base_url, proxy_address, proxy_port, proxy_user, proxy_pass)
|
35
35
|
@_cache_policy = AutoPollingCachePolicy.new(@_config_fetcher, @_config_cache, poll_interval_seconds, max_init_wait_time_seconds, on_configuration_changed_callback)
|
36
36
|
else
|
37
37
|
if cache_time_to_live_seconds > 0
|
38
|
-
@_config_fetcher = CacheControlConfigFetcher.new(
|
38
|
+
@_config_fetcher = CacheControlConfigFetcher.new(sdk_key, "l", base_url, proxy_address, proxy_port, proxy_user, proxy_pass)
|
39
39
|
@_cache_policy = LazyLoadingCachePolicy.new(@_config_fetcher, @_config_cache, cache_time_to_live_seconds)
|
40
40
|
else
|
41
|
-
@_config_fetcher = CacheControlConfigFetcher.new(
|
41
|
+
@_config_fetcher = CacheControlConfigFetcher.new(sdk_key, "m", base_url, proxy_address, proxy_port, proxy_user, proxy_pass)
|
42
42
|
@_cache_policy = ManualPollingCachePolicy.new(@_config_fetcher, @_config_cache)
|
43
43
|
end
|
44
44
|
end
|
@@ -32,8 +32,8 @@ module ConfigCat
|
|
32
32
|
end
|
33
33
|
|
34
34
|
class CacheControlConfigFetcher < ConfigFetcher
|
35
|
-
def initialize(
|
36
|
-
@
|
35
|
+
def initialize(sdk_key, mode, base_url=nil, proxy_address=nil, proxy_port=nil, proxy_user=nil, proxy_pass=nil)
|
36
|
+
@_sdk_key = sdk_key
|
37
37
|
@_etag = ""
|
38
38
|
@_headers = {"User-Agent" => ((("ConfigCat-Ruby/") + mode) + ("-")) + VERSION, "X-ConfigCat-UserAgent" => ((("ConfigCat-Ruby/") + mode) + ("-")) + VERSION, "Content-Type" => "application/json"}
|
39
39
|
if !base_url.equal?(nil)
|
@@ -51,7 +51,7 @@ module ConfigCat
|
|
51
51
|
# Returns the FetchResponse object contains configuration json Dictionary
|
52
52
|
def get_configuration_json()
|
53
53
|
ConfigCat.logger.debug "Fetching configuration from ConfigCat"
|
54
|
-
uri = URI.parse((((@_base_url + ("/")) + BASE_PATH) + @
|
54
|
+
uri = URI.parse((((@_base_url + ("/")) + BASE_PATH) + @_sdk_key) + BASE_EXTENSION)
|
55
55
|
headers = @_headers
|
56
56
|
headers["If-None-Match"] = @_etag unless @_etag.empty?
|
57
57
|
request = Net::HTTP::Get.new(uri.request_uri, headers)
|
@@ -52,7 +52,7 @@ module ConfigCat
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
rescue StandardError => e
|
55
|
-
ConfigCat.logger.error("Double-check your
|
55
|
+
ConfigCat.logger.error("Double-check your SDK Key at https://app.configcat.com/sdkkey.")
|
56
56
|
ConfigCat.logger.error "threw exception #{e.class}:'#{e}'"
|
57
57
|
ConfigCat.logger.error "stacktrace: #{e.backtrace}"
|
58
58
|
end
|
@@ -32,7 +32,7 @@ module ConfigCat
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
rescue StandardError => e
|
35
|
-
ConfigCat.logger.error("Double-check your
|
35
|
+
ConfigCat.logger.error("Double-check your SDK Key at https://app.configcat.com/sdkkey.")
|
36
36
|
ConfigCat.logger.error "threw exception #{e.class}:'#{e}'"
|
37
37
|
ConfigCat.logger.error "stacktrace: #{e.backtrace}"
|
38
38
|
end
|
data/lib/configcat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configcat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ConfigCat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|