flagsmith 4.1.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -2
- data/lib/flagsmith/sdk/config.rb +4 -1
- data/lib/flagsmith/sdk/pooling_manager.rb +15 -2
- data/lib/flagsmith/version.rb +1 -1
- data/lib/flagsmith.rb +2 -2
- 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: 8b908dee8f4935d4c754400d2e314e8a61e545dc242490ca396704f6b00ef1e1
|
4
|
+
data.tar.gz: 4c9203ad57f71fb3699b78ccb9a50aa7b4c89eaf1433803d0c16e3b7644a91c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a41d33186ccd7bf6b7405a123186888ea9aef9e0890762b2384d1681b897ceed602e471eb4903190bf09b0c1c48a6b99a831053f10dde55cbcd6e9875851dfde
|
7
|
+
data.tar.gz: e654da93bb040ce2a08fa0cb6b15d167a2b557853fec1e8deb3cd45df124177998d7fb40e6ccae777cf8e62b0cdc72efd0cbd3a8e6fd4fcd894ed2b23d228c90
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
flagsmith (4.1.
|
4
|
+
flagsmith (4.1.1)
|
5
5
|
faraday (>= 2.0.1)
|
6
6
|
faraday-retry
|
7
7
|
semantic
|
@@ -39,7 +39,8 @@ GEM
|
|
39
39
|
rainbow (3.1.1)
|
40
40
|
rake (13.1.0)
|
41
41
|
regexp_parser (2.9.0)
|
42
|
-
rexml (3.2.
|
42
|
+
rexml (3.2.8)
|
43
|
+
strscan (>= 3.0.9)
|
43
44
|
rspec (3.12.0)
|
44
45
|
rspec-core (~> 3.12.0)
|
45
46
|
rspec-expectations (~> 3.12.0)
|
@@ -68,6 +69,7 @@ GEM
|
|
68
69
|
parser (>= 3.2.1.0)
|
69
70
|
ruby-progressbar (1.13.0)
|
70
71
|
semantic (1.6.1)
|
72
|
+
strscan (3.1.0)
|
71
73
|
unicode-display_width (2.5.0)
|
72
74
|
uri (0.13.0)
|
73
75
|
|
data/lib/flagsmith/sdk/config.rb
CHANGED
@@ -7,7 +7,7 @@ module Flagsmith
|
|
7
7
|
OPTIONS = %i[
|
8
8
|
environment_key api_url custom_headers request_timeout_seconds enable_local_evaluation
|
9
9
|
environment_refresh_interval_seconds retries enable_analytics default_flag_handler
|
10
|
-
offline_mode offline_handler logger
|
10
|
+
offline_mode offline_handler polling_manager_failure_limit logger
|
11
11
|
].freeze
|
12
12
|
|
13
13
|
# Available Configs
|
@@ -38,6 +38,8 @@ module Flagsmith
|
|
38
38
|
# bypasses requests to the api.
|
39
39
|
# +offline_handler+ - A file object that contains a JSON serialization of
|
40
40
|
# the entire environment, project, flags, etc.
|
41
|
+
# +polling_manager_failure_limit+ - An integer to control how long to suppress errors in
|
42
|
+
# the polling manager for local evaluation mode.
|
41
43
|
# +logger+ - Pass your logger, default is Logger.new($stdout)
|
42
44
|
#
|
43
45
|
attr_reader(*OPTIONS)
|
@@ -89,6 +91,7 @@ module Flagsmith
|
|
89
91
|
@default_flag_handler = opts[:default_flag_handler]
|
90
92
|
@offline_mode = opts.fetch(:offline_mode, false)
|
91
93
|
@offline_handler = opts[:offline_handler]
|
94
|
+
@polling_manager_failure_limit = opts.fetch(:polling_manager_failure_limit, 10)
|
92
95
|
@logger = options.fetch(:logger, Logger.new($stdout).tap { |l| l.level = :debug })
|
93
96
|
end
|
94
97
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
@@ -7,20 +7,33 @@ module Flagsmith
|
|
7
7
|
class EnvironmentDataPollingManager
|
8
8
|
include Flagsmith::SDK::Intervals
|
9
9
|
|
10
|
-
|
10
|
+
attr_reader :failures_since_last_update
|
11
|
+
|
12
|
+
def initialize(main, refresh_interval_seconds, polling_manager_failure_limit)
|
11
13
|
@main = main
|
12
14
|
@refresh_interval_seconds = refresh_interval_seconds
|
15
|
+
@polling_manager_failure_limit = polling_manager_failure_limit
|
16
|
+
@failures_since_last_update = 0
|
13
17
|
end
|
14
18
|
|
19
|
+
# rubocop:disable Metrics/MethodLength
|
15
20
|
def start
|
16
21
|
update_environment = lambda {
|
17
22
|
stop
|
18
|
-
@interval = set_interval(@refresh_interval_seconds)
|
23
|
+
@interval = set_interval(@refresh_interval_seconds) do
|
24
|
+
@main.update_environment
|
25
|
+
@failures_since_last_update = 0
|
26
|
+
rescue StandardError => e
|
27
|
+
@failures_since_last_update += 1
|
28
|
+
@main.config.logger.warn "Failure to update the environment due to an error: #{e}"
|
29
|
+
raise e if @failures_since_last_update > @polling_manager_failure_limit
|
30
|
+
end
|
19
31
|
}
|
20
32
|
|
21
33
|
# TODO: this call should be awaited for getIdentityFlags/getEnvironmentFlags when enableLocalEvaluation is true
|
22
34
|
update_environment.call
|
23
35
|
end
|
36
|
+
# rubocop:enable Metrics/MethodLength
|
24
37
|
|
25
38
|
def stop
|
26
39
|
return unless @interval
|
data/lib/flagsmith/version.rb
CHANGED
data/lib/flagsmith.rb
CHANGED
@@ -45,7 +45,7 @@ module Flagsmith
|
|
45
45
|
#
|
46
46
|
# :environment_key, :api_url, :custom_headers, :request_timeout_seconds, :enable_local_evaluation,
|
47
47
|
# :environment_refresh_interval_seconds, :retries, :enable_analytics, :default_flag_handler,
|
48
|
-
# :offline_mode, :offline_handler
|
48
|
+
# :offline_mode, :offline_handler, :polling_manager_failure_limit
|
49
49
|
#
|
50
50
|
# You can see full description in the Flagsmith::Config
|
51
51
|
|
@@ -107,7 +107,7 @@ module Flagsmith
|
|
107
107
|
update_environment if @environment_data_polling_manager.nil?
|
108
108
|
|
109
109
|
@environment_data_polling_manager ||= Flagsmith::EnvironmentDataPollingManager.new(
|
110
|
-
self, environment_refresh_interval_seconds
|
110
|
+
self, environment_refresh_interval_seconds, @config.polling_manager_failure_limit
|
111
111
|
).tap(&:start)
|
112
112
|
end
|
113
113
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flagsmith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Stuart
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-05-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|