configcat 2.0.3 → 2.0.5
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: 805c9d54b6d9b24a12dfb2da3fdb8f7f9c22ee07a37c0be1c08e800a79fcee99
|
4
|
+
data.tar.gz: 5cfccd8b9225f636d2c8d5f4fb24d92658f13612fa091d8b30593a5569261891
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06bbc69993cc02cf6912ca7e6518910ac1154049d78636597ae1431f761aa887b1ecafb665b3b93a4d1bca51ec0177dc2e59ee746ed768496dc35e31d3369bdd
|
7
|
+
data.tar.gz: 1bf9ca51425faf2c2a5b1346e09dfa87c8f382e7dfe0d828016607597fe28b7c29174696da41a4bb13e69befd58708c78e51fe57305bfdb79fabdb507d558d0a
|
@@ -48,7 +48,7 @@ module ConfigCat
|
|
48
48
|
|
49
49
|
def force_refresh()
|
50
50
|
begin
|
51
|
-
|
51
|
+
configuration_response = @_config_fetcher.get_configuration_json()
|
52
52
|
|
53
53
|
begin
|
54
54
|
@_lock.acquire_read_lock()
|
@@ -57,20 +57,23 @@ module ConfigCat
|
|
57
57
|
@_lock.release_read_lock()
|
58
58
|
end
|
59
59
|
|
60
|
-
if
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
60
|
+
if configuration_response.is_fetched()
|
61
|
+
configuration = configuration_response.json()
|
62
|
+
if configuration != old_configuration
|
63
|
+
begin
|
64
|
+
@_lock.acquire_write_lock()
|
65
|
+
@_config_cache.set(configuration)
|
66
|
+
@_initialized = true
|
67
|
+
ensure
|
68
|
+
@_lock.release_write_lock()
|
69
|
+
end
|
70
|
+
begin
|
71
|
+
if !@_on_configuration_changed_callback.equal?(nil)
|
72
|
+
@_on_configuration_changed_callback.()
|
73
|
+
end
|
74
|
+
rescue Exception => e
|
75
|
+
ConfigCat.logger.error("Exception in on_configuration_changed_callback: #{e.class}:'#{e}'")
|
71
76
|
end
|
72
|
-
rescue Exception => e
|
73
|
-
ConfigCat.logger.error("Exception in on_configuration_changed_callback: #{e.class}:'#{e}'")
|
74
77
|
end
|
75
78
|
end
|
76
79
|
|
@@ -9,10 +9,32 @@ module ConfigCat
|
|
9
9
|
BASE_PATH = "configuration-files/"
|
10
10
|
BASE_EXTENSION = "/config_v4.json"
|
11
11
|
|
12
|
+
class FetchResponse
|
13
|
+
def initialize(response)
|
14
|
+
@_response = response
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns the json-encoded content of a response, if any
|
18
|
+
def json()
|
19
|
+
return JSON.parse(@_response.body)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Gets whether a new configuration value was fetched or not
|
23
|
+
def is_fetched()
|
24
|
+
code = @_response.code.to_i
|
25
|
+
return 200 <= code && code < 300
|
26
|
+
end
|
27
|
+
|
28
|
+
# Gets whether the fetch resulted a '304 Not Modified' or not
|
29
|
+
def is_not_modified()
|
30
|
+
return @_response.code == "304"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
12
34
|
class CacheControlConfigFetcher < ConfigFetcher
|
13
35
|
def initialize(api_key, mode, base_url=nil, proxy_address=nil, proxy_port=nil, proxy_user=nil, proxy_pass=nil)
|
14
36
|
@_api_key = api_key
|
15
|
-
@_etag =
|
37
|
+
@_etag = ""
|
16
38
|
@_headers = {"User-Agent" => ((("ConfigCat-Ruby/") + mode) + ("-")) + VERSION, "X-ConfigCat-UserAgent" => ((("ConfigCat-Ruby/") + mode) + ("-")) + VERSION, "Content-Type" => "application/json"}
|
17
39
|
if !base_url.equal?(nil)
|
18
40
|
@_base_url = base_url.chomp("/")
|
@@ -26,16 +48,18 @@ module ConfigCat
|
|
26
48
|
@_http.read_timeout = 30 # in seconds
|
27
49
|
end
|
28
50
|
|
51
|
+
# Returns the FetchResponse object contains configuration json Dictionary
|
29
52
|
def get_configuration_json()
|
30
53
|
ConfigCat.logger.debug "Fetching configuration from ConfigCat"
|
31
54
|
uri = URI.parse((((@_base_url + ("/")) + BASE_PATH) + @_api_key) + BASE_EXTENSION)
|
32
|
-
|
33
|
-
|
55
|
+
headers = @_headers
|
56
|
+
headers["If-None-Match"] = @_etag unless @_etag.empty?
|
57
|
+
request = Net::HTTP::Get.new(uri.request_uri, headers)
|
34
58
|
response = @_http.request(request)
|
35
|
-
|
36
|
-
@_etag =
|
59
|
+
etag = response["ETag"]
|
60
|
+
@_etag = etag unless etag.nil? || etag.empty?
|
37
61
|
ConfigCat.logger.debug "ConfigCat configuration json fetch response code:#{response.code} Cached:#{response['ETag']}"
|
38
|
-
return
|
62
|
+
return FetchResponse.new(response)
|
39
63
|
end
|
40
64
|
|
41
65
|
def close()
|
@@ -40,13 +40,16 @@ module ConfigCat
|
|
40
40
|
|
41
41
|
def force_refresh()
|
42
42
|
begin
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
configuration_response = @_config_fetcher.get_configuration_json()
|
44
|
+
if configuration_response.is_fetched()
|
45
|
+
configuration = configuration_response.json()
|
46
|
+
begin
|
47
|
+
@_lock.acquire_write_lock()
|
48
|
+
@_config_cache.set(configuration)
|
49
|
+
@_last_updated = Time.now.utc
|
50
|
+
ensure
|
51
|
+
@_lock.release_write_lock()
|
52
|
+
end
|
50
53
|
end
|
51
54
|
rescue StandardError => e
|
52
55
|
ConfigCat.logger.error("Double-check your API KEY at https://app.configcat.com/apikey.")
|
@@ -21,12 +21,15 @@ module ConfigCat
|
|
21
21
|
|
22
22
|
def force_refresh()
|
23
23
|
begin
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
configuration_response = @_config_fetcher.get_configuration_json()
|
25
|
+
if configuration_response.is_fetched()
|
26
|
+
configuration = configuration_response.json()
|
27
|
+
begin
|
28
|
+
@_lock.acquire_write_lock()
|
29
|
+
@_config_cache.set(configuration)
|
30
|
+
ensure
|
31
|
+
@_lock.release_write_lock()
|
32
|
+
end
|
30
33
|
end
|
31
34
|
rescue StandardError => e
|
32
35
|
ConfigCat.logger.error("Double-check your API KEY at https://app.configcat.com/apikey.")
|
data/lib/configcat/version.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configcat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
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-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: semantic
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,30 +56,44 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '12.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '12.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: coveralls
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.8'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
89
|
+
version: '3.0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - "
|
94
|
+
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
96
|
+
version: '3.0'
|
83
97
|
description: Feature Flags created by developers for developers with ❤️. ConfigCat
|
84
98
|
lets you manage feature flags across frontend, backend, mobile, and desktop apps
|
85
99
|
without (re)deploying code. % rollouts, user targeting, segmentation. Feature toggle
|
@@ -112,7 +126,7 @@ require_paths:
|
|
112
126
|
- lib
|
113
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- - "
|
129
|
+
- - ">="
|
116
130
|
- !ruby/object:Gem::Version
|
117
131
|
version: '2.2'
|
118
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|