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: 5a763908060912e846143f8b486c77b0eac1c3438cb49f52bc60dbb3d282c871
4
- data.tar.gz: 1969cdef03d2d57ee1c12c3d6ff24f4ec2db0e853a5da07cc01e1179c898aeb7
3
+ metadata.gz: 805c9d54b6d9b24a12dfb2da3fdb8f7f9c22ee07a37c0be1c08e800a79fcee99
4
+ data.tar.gz: 5cfccd8b9225f636d2c8d5f4fb24d92658f13612fa091d8b30593a5569261891
5
5
  SHA512:
6
- metadata.gz: f6234c399e25efe60c3735baf1f96c2d28aa8bd9b90e4e65001cd21ccdd2a49965a09d1311303003ef00691dcf9078743a6f6fafe2317c73977f8e3a62b5cdf0
7
- data.tar.gz: 3759554dc40d9ad8e5ef86da9c80acf1eeaebeef18daf86d27328a8a0a1f52b91df02ad5f0677b6e10f6667f20496bed3d0b6377d02771e4899b3bda3ec5951a
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
- configuration = @_config_fetcher.get_configuration_json()
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 configuration != old_configuration
61
- begin
62
- @_lock.acquire_write_lock()
63
- @_config_cache.set(configuration)
64
- @_initialized = true
65
- ensure
66
- @_lock.release_write_lock()
67
- end
68
- begin
69
- if !@_on_configuration_changed_callback.equal?(nil)
70
- @_on_configuration_changed_callback.()
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 = nil
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
- @_headers["If-None-Match"] = @_etag unless @_etag.nil?
33
- request = Net::HTTP::Get.new(uri.request_uri, @_headers)
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
- json = JSON.parse(response.body)
36
- @_etag = response["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 json
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
- configuration = @_config_fetcher.get_configuration_json()
44
- begin
45
- @_lock.acquire_write_lock()
46
- @_config_cache.set(configuration)
47
- @_last_updated = Time.now.utc
48
- ensure
49
- @_lock.release_write_lock()
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
- configuration = @_config_fetcher.get_configuration_json()
25
- begin
26
- @_lock.acquire_write_lock()
27
- @_config_cache.set(configuration)
28
- ensure
29
- @_lock.release_write_lock()
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.")
@@ -1,3 +1,3 @@
1
1
  module ConfigCat
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.5"
3
3
  end
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.3
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-02-26 00:00:00.000000000 Z
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: '0'
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: '0'
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: '0'
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: '0'
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: '0'
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: '0'
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