splitclient-rb 8.1.2.pre.rc1-java → 8.1.3.pre.rc1-java
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/CHANGES.txt +1 -1
- data/README.md +16 -10
- data/lib/splitclient-rb/cache/fetchers/split_fetcher.rb +5 -5
- data/lib/splitclient-rb/cache/stores/localhost_split_store.rb +2 -2
- data/lib/splitclient-rb/clients/split_client.rb +10 -10
- data/lib/splitclient-rb/engine/api/splits.rb +4 -4
- data/lib/splitclient-rb/engine/matchers/dependency_matcher.rb +5 -5
- data/lib/splitclient-rb/engine/synchronizer.rb +1 -1
- data/lib/splitclient-rb/helpers/decryption_helper.rb +25 -0
- data/lib/splitclient-rb/managers/split_manager.rb +10 -10
- data/lib/splitclient-rb/sse/notification_processor.rb +2 -6
- data/lib/splitclient-rb/sse/workers/splits_worker.rb +49 -17
- data/lib/splitclient-rb/validators.rb +1 -1
- data/lib/splitclient-rb/version.rb +1 -1
- data/lib/splitclient-rb.rb +1 -0
- data/splitclient-rb.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aeedfe4b86ecd8ca68ce4a5f309758f48f7cbc1
|
4
|
+
data.tar.gz: b1c284a4d23b41582e0e58fd8f827b10e13490d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cea9bc6609a23fd184f1e406fac905b06e1df66db297027b28ada289e17d7d46be7f58b4f7a8a2f26ff04287e146344b606c0a284c4acba8d537fa262fbad867
|
7
|
+
data.tar.gz: a26df41524283c15ddc5935b8151a533624b56bd71e24f6d6c0514f024281b77ee970314b8c36f52c4922dc5574b8998adccd298a0e96a0050b16b008bd9ee51
|
data/CHANGES.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
CHANGES
|
2
2
|
|
3
3
|
8.1.2 (May 15, 2023)
|
4
|
-
- Updated terminology on the SDKs codebase to be more aligned with current standard without causing a breaking change. The core change is the term split for feature flag on things like logs and
|
4
|
+
- Updated terminology on the SDKs codebase to be more aligned with current standard without causing a breaking change. The core change is the term split for feature flag on things like logs and IntelliSense comments.
|
5
5
|
|
6
6
|
8.1.1 (Mar 17, 2023)
|
7
7
|
- Added retries with backoff when the sdk tries to connect to the Streaming service and it is not available.
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Split SDK for Ruby
|
2
|
-
](https://github.com/splitio/ruby-client/actions)
|
3
|
+
[](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
|
3
4
|
|
4
5
|
## Overview
|
5
|
-
This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via
|
6
|
+
This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via feature flags to manage your complete customer experience.
|
6
7
|
|
7
8
|
[](https://twitter.com/intent/follow?screen_name=splitsoftware)
|
8
9
|
|
@@ -21,7 +22,7 @@ Below is a simple example that describes the instantiation and most basic usage
|
|
21
22
|
```ruby
|
22
23
|
require 'splitclient-rb'
|
23
24
|
|
24
|
-
split_factory = SplitIoClient::SplitFactory.new('
|
25
|
+
split_factory = SplitIoClient::SplitFactory.new('YOUR_SDK_KEY')
|
25
26
|
split_client = split_factory.client
|
26
27
|
|
27
28
|
begin
|
@@ -30,7 +31,7 @@ rescue SplitIoClient::SDKBlockerTimeoutExpiredException
|
|
30
31
|
puts 'SDK is not ready. Decide whether to continue or abort execution'
|
31
32
|
end
|
32
33
|
|
33
|
-
treatment = split_client.get_treatment('CUSTOMER_ID', '
|
34
|
+
treatment = split_client.get_treatment('CUSTOMER_ID', 'FEATURE_FLAG_NAME');
|
34
35
|
|
35
36
|
if treatment == 'on'
|
36
37
|
# insert code here to show on treatment
|
@@ -60,16 +61,21 @@ To learn more about Split, contact hello@split.io, or get started with feature f
|
|
60
61
|
|
61
62
|
Split has built and maintains SDKs for:
|
62
63
|
|
64
|
+
* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
|
65
|
+
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
|
66
|
+
* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
|
67
|
+
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
|
68
|
+
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
|
63
69
|
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
|
64
|
-
*
|
70
|
+
* JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
|
71
|
+
* JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
|
65
72
|
* Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
|
66
|
-
* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
|
67
|
-
* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
|
68
73
|
* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
|
69
74
|
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
|
70
|
-
*
|
71
|
-
*
|
72
|
-
*
|
75
|
+
* React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)
|
76
|
+
* React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK)
|
77
|
+
* Redux [Github](https://github.com/splitio/redux-client) [Docs](https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK)
|
78
|
+
* Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
|
73
79
|
|
74
80
|
For a comprehensive list of open source projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).
|
75
81
|
|
@@ -49,12 +49,12 @@ module SplitIoClient
|
|
49
49
|
|
50
50
|
def splits_thread
|
51
51
|
@config.threads[:split_fetcher] = Thread.new do
|
52
|
-
@config.logger.info('Starting
|
52
|
+
@config.logger.info('Starting feature flags fetcher service') if @config.debug_enabled
|
53
53
|
loop do
|
54
54
|
fetch_splits
|
55
55
|
|
56
56
|
sleep_for = SplitIoClient::Cache::Stores::StoreUtils.random_interval(@config.features_refresh_rate)
|
57
|
-
@config.logger.debug("
|
57
|
+
@config.logger.debug("Feature flags fetcher is sleeping for: #{sleep_for} seconds") if @config.debug_enabled
|
58
58
|
sleep(sleep_for)
|
59
59
|
end
|
60
60
|
end
|
@@ -66,7 +66,7 @@ module SplitIoClient
|
|
66
66
|
|
67
67
|
def add_split_unless_archived(split)
|
68
68
|
if Engine::Models::Split.archived?(split)
|
69
|
-
@config.logger.debug("Seeing archived
|
69
|
+
@config.logger.debug("Seeing archived feature flag #{split[:name]}") if @config.debug_enabled
|
70
70
|
|
71
71
|
remove_archived_split(split)
|
72
72
|
else
|
@@ -75,13 +75,13 @@ module SplitIoClient
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def remove_archived_split(split)
|
78
|
-
@config.logger.debug("removing
|
78
|
+
@config.logger.debug("removing feature flag from store(#{split})") if @config.debug_enabled
|
79
79
|
|
80
80
|
@splits_repository.remove_split(split)
|
81
81
|
end
|
82
82
|
|
83
83
|
def store_split(split)
|
84
|
-
@config.logger.debug("storing
|
84
|
+
@config.logger.debug("storing feature flag (#{split[:name]})") if @config.debug_enabled
|
85
85
|
|
86
86
|
@splits_repository.add_split(split)
|
87
87
|
end
|
@@ -31,7 +31,7 @@ module SplitIoClient
|
|
31
31
|
|
32
32
|
def splits_thread
|
33
33
|
@config.threads[:split_store] = Thread.new do
|
34
|
-
@config.logger.info('Starting
|
34
|
+
@config.logger.info('Starting feature flags fetcher service')
|
35
35
|
loop do
|
36
36
|
store_splits
|
37
37
|
|
@@ -53,7 +53,7 @@ module SplitIoClient
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def store_split(split)
|
56
|
-
@config.logger.debug("storing
|
56
|
+
@config.logger.debug("storing feature flag (#{split[:name]})") if @config.debug_enabled
|
57
57
|
|
58
58
|
@splits_repository.add_split(split)
|
59
59
|
end
|
@@ -11,11 +11,11 @@ module SplitIoClient
|
|
11
11
|
#
|
12
12
|
# Creates a new split client instance that connects to split.io API.
|
13
13
|
#
|
14
|
-
# @param
|
14
|
+
# @param sdk_key [String] the SDK key for your split account
|
15
15
|
#
|
16
16
|
# @return [SplitIoClient] split.io client instance
|
17
|
-
def initialize(
|
18
|
-
@api_key =
|
17
|
+
def initialize(sdk_key, repositories, status_manager, config, impressions_manager, telemetry_evaluation_producer)
|
18
|
+
@api_key = sdk_key
|
19
19
|
@splits_repository = repositories[:splits]
|
20
20
|
@segments_repository = repositories[:segments]
|
21
21
|
@impressions_repository = repositories[:impressions]
|
@@ -103,8 +103,8 @@ module SplitIoClient
|
|
103
103
|
|
104
104
|
if ready? && !@config.localhost_mode && !@splits_repository.traffic_type_exists(traffic_type_name)
|
105
105
|
@config.logger.warn("track: Traffic Type #{traffic_type_name} " \
|
106
|
-
"does not have any corresponding
|
107
|
-
'your events to a valid traffic type defined in the Split
|
106
|
+
"does not have any corresponding feature flags in this environment, make sure you're tracking " \
|
107
|
+
'your events to a valid traffic type defined in the Split user interface')
|
108
108
|
end
|
109
109
|
|
110
110
|
@events_repository.add(key.to_s, traffic_type_name.downcase, event_type.to_s, (Time.now.to_f * 1000).to_i, value, properties, properties_size)
|
@@ -147,10 +147,10 @@ module SplitIoClient
|
|
147
147
|
if (split_name.is_a?(String) || split_name.is_a?(Symbol)) && !split_name.empty?
|
148
148
|
true
|
149
149
|
elsif split_name.is_a?(String) && split_name.empty?
|
150
|
-
@config.logger.warn("#{calling_method}: you passed an empty
|
150
|
+
@config.logger.warn("#{calling_method}: you passed an empty feature_flag_name, flag name must be a non-empty String or a Symbol")
|
151
151
|
false
|
152
152
|
else
|
153
|
-
@config.logger.warn("#{calling_method}: you passed an invalid
|
153
|
+
@config.logger.warn("#{calling_method}: you passed an invalid feature_flag_name, flag name must be a non-empty String or a Symbol")
|
154
154
|
false
|
155
155
|
end
|
156
156
|
end
|
@@ -200,7 +200,7 @@ module SplitIoClient
|
|
200
200
|
sanitized_split_names = sanitize_split_names(calling_method, split_names)
|
201
201
|
|
202
202
|
if sanitized_split_names.empty?
|
203
|
-
@config.logger.error("#{calling_method}:
|
203
|
+
@config.logger.error("#{calling_method}: feature_flag_names must be a non-empty Array")
|
204
204
|
return {}
|
205
205
|
end
|
206
206
|
|
@@ -258,7 +258,7 @@ module SplitIoClient
|
|
258
258
|
sanitized_split_name = split_name.to_s.strip
|
259
259
|
|
260
260
|
if split_name.to_s != sanitized_split_name
|
261
|
-
@config.logger.warn("#{calling_method}:
|
261
|
+
@config.logger.warn("#{calling_method}: feature_flag_name #{split_name} has extra whitespace, trimming")
|
262
262
|
split_name = sanitized_split_name
|
263
263
|
end
|
264
264
|
|
@@ -271,7 +271,7 @@ module SplitIoClient
|
|
271
271
|
|
272
272
|
if split.nil? && ready?
|
273
273
|
@config.logger.warn("#{calling_method}: you passed #{split_name} that " \
|
274
|
-
'does not exist in this environment, please double check what
|
274
|
+
'does not exist in this environment, please double check what feature flags exist in the Split user interface')
|
275
275
|
|
276
276
|
return parsed_treatment(multiple, control_treatment.merge({ label: Engine::Models::Label::NOT_FOUND }))
|
277
277
|
end
|
@@ -20,9 +20,9 @@ module SplitIoClient
|
|
20
20
|
result = splits_with_segment_names(response.body)
|
21
21
|
|
22
22
|
unless result[:splits].empty?
|
23
|
-
@config.split_logger.log_if_debug("#{result[:splits].length}
|
23
|
+
@config.split_logger.log_if_debug("#{result[:splits].length} feature flags retrieved. since=#{since}")
|
24
24
|
end
|
25
|
-
@config.split_logger.log_if_transport("
|
25
|
+
@config.split_logger.log_if_transport("Feature flag changes response: #{result.to_s}")
|
26
26
|
|
27
27
|
bucket = BinarySearchLatencyTracker.get_bucket((Time.now - start) * 1000.0)
|
28
28
|
@telemetry_runtime_producer.record_sync_latency(Telemetry::Domain::Constants::SPLIT_SYNC, bucket)
|
@@ -32,10 +32,10 @@ module SplitIoClient
|
|
32
32
|
else
|
33
33
|
@telemetry_runtime_producer.record_sync_error(Telemetry::Domain::Constants::SPLIT_SYNC, response.status)
|
34
34
|
|
35
|
-
@config.logger.error("Unexpected status code while fetching
|
35
|
+
@config.logger.error("Unexpected status code while fetching feature flags: #{response.status}. " \
|
36
36
|
'Check your API key and base URI')
|
37
37
|
|
38
|
-
raise 'Split SDK failed to connect to backend to fetch
|
38
|
+
raise 'Split SDK failed to connect to backend to fetch feature flags definitions'
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -4,18 +4,18 @@ module SplitIoClient
|
|
4
4
|
class DependencyMatcher
|
5
5
|
MATCHER_TYPE = 'IN_SPLIT_TREATMENT'
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(feature_flag, treatments, logger)
|
8
|
+
@feature_flag = feature_flag
|
9
9
|
@treatments = treatments
|
10
10
|
@logger = logger
|
11
11
|
end
|
12
12
|
|
13
13
|
def match?(args)
|
14
14
|
keys = { matching_key: args[:matching_key], bucketing_key: args[:bucketing_key] }
|
15
|
-
evaluate = args[:evaluator].call(keys, @
|
15
|
+
evaluate = args[:evaluator].call(keys, @feature_flag, args[:attributes])
|
16
16
|
matches = @treatments.include?(evaluate[:treatment])
|
17
|
-
@logger.log_if_debug("[dependencyMatcher] Parent
|
18
|
-
with label #{evaluate[:label]}. #{@
|
17
|
+
@logger.log_if_debug("[dependencyMatcher] Parent feature flag #{@feature_flag} evaluated to #{evaluate[:treatment]} \
|
18
|
+
with label #{evaluate[:label]}. #{@feature_flag} evaluated treatment is part of [#{@treatments}] ? #{matches}.")
|
19
19
|
matches
|
20
20
|
end
|
21
21
|
|
@@ -201,7 +201,7 @@ module SplitIoClient
|
|
201
201
|
end
|
202
202
|
|
203
203
|
def sync_splits_and_segments
|
204
|
-
@config.logger.debug('Synchronizing
|
204
|
+
@config.logger.debug('Synchronizing feature flags and segments ...') if @config.debug_enabled
|
205
205
|
splits_result = @split_fetcher.fetch_splits
|
206
206
|
|
207
207
|
splits_result[:success] && @segment_fetcher.fetch_segments
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SplitIoClient
|
4
|
+
NO_COMPRESSION = 0
|
5
|
+
GZIP_COMPRESSION = 1
|
6
|
+
ZLIB_COMPRESSION = 2
|
7
|
+
|
8
|
+
module Helpers
|
9
|
+
class DecryptionHelper
|
10
|
+
def self.get_encoded_definition(compression, data)
|
11
|
+
case compression
|
12
|
+
when NO_COMPRESSION
|
13
|
+
Base64.decode64(data)
|
14
|
+
when GZIP_COMPRESSION
|
15
|
+
gz = Zlib::GzipReader.new(StringIO.new(Base64.decode64(data)))
|
16
|
+
gz.read
|
17
|
+
when ZLIB_COMPRESSION
|
18
|
+
Zlib::Inflate.inflate(Base64.decode64(data))
|
19
|
+
else
|
20
|
+
raise StandardError, 'Compression flag value is incorrect'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -50,31 +50,31 @@ module SplitIoClient
|
|
50
50
|
# method to get a split view
|
51
51
|
#
|
52
52
|
# @returns a split view
|
53
|
-
def split(
|
54
|
-
return unless @config.valid_mode && @splits_repository && @config.split_validator.valid_split_parameters(
|
53
|
+
def split(feature_flag_name)
|
54
|
+
return unless @config.valid_mode && @splits_repository && @config.split_validator.valid_split_parameters(feature_flag_name)
|
55
55
|
|
56
56
|
if !ready?
|
57
57
|
@config.logger.error("split: the SDK is not ready, the operation cannot be executed")
|
58
58
|
return
|
59
59
|
end
|
60
60
|
|
61
|
-
|
61
|
+
sanitized_feature_flag_name = feature_flag_name.to_s.strip
|
62
62
|
|
63
|
-
if
|
64
|
-
@config.logger.warn("split:
|
65
|
-
|
63
|
+
if feature_flag_name.to_s != sanitized_feature_flag_name
|
64
|
+
@config.logger.warn("split: feature_flag_name #{feature_flag_name} has extra whitespace, trimming")
|
65
|
+
feature_flag_name = sanitized_feature_flag_name
|
66
66
|
end
|
67
67
|
|
68
|
-
split = @splits_repository.get_split(
|
68
|
+
split = @splits_repository.get_split(feature_flag_name)
|
69
69
|
|
70
70
|
if ready? && split.nil?
|
71
|
-
@config.logger.warn("split: you passed #{
|
72
|
-
'that does not exist in this environment, please double check what
|
71
|
+
@config.logger.warn("split: you passed #{feature_flag_name} " \
|
72
|
+
'that does not exist in this environment, please double check what feature flags exist in the Split user interface')
|
73
73
|
end
|
74
74
|
|
75
75
|
return if split.nil? || Engine::Models::Split.archived?(split)
|
76
76
|
|
77
|
-
build_split_view(
|
77
|
+
build_split_view(feature_flag_name, split)
|
78
78
|
end
|
79
79
|
|
80
80
|
def block_until_ready(time = nil)
|
@@ -26,16 +26,12 @@ module SplitIoClient
|
|
26
26
|
|
27
27
|
def process_split_update(notification)
|
28
28
|
@config.logger.debug("SPLIT UPDATE notification received: #{notification}") if @config.debug_enabled
|
29
|
-
@splits_worker.add_to_queue(notification
|
29
|
+
@splits_worker.add_to_queue(notification)
|
30
30
|
end
|
31
31
|
|
32
32
|
def process_split_kill(notification)
|
33
33
|
@config.logger.debug("SPLIT KILL notification received: #{notification}") if @config.debug_enabled
|
34
|
-
|
35
|
-
default_treatment = notification.data['defaultTreatment']
|
36
|
-
split_name = notification.data['splitName']
|
37
|
-
|
38
|
-
@splits_worker.kill_split(change_number, split_name, default_treatment)
|
34
|
+
@splits_worker.add_to_queue(notification)
|
39
35
|
end
|
40
36
|
|
41
37
|
def process_segment_update(notification)
|
@@ -4,17 +4,17 @@ module SplitIoClient
|
|
4
4
|
module SSE
|
5
5
|
module Workers
|
6
6
|
class SplitsWorker
|
7
|
-
def initialize(synchronizer, config,
|
7
|
+
def initialize(synchronizer, config, feature_flags_repository)
|
8
8
|
@synchronizer = synchronizer
|
9
9
|
@config = config
|
10
|
-
@
|
10
|
+
@feature_flags_repository = feature_flags_repository
|
11
11
|
@queue = Queue.new
|
12
12
|
@running = Concurrent::AtomicBoolean.new(false)
|
13
13
|
end
|
14
14
|
|
15
15
|
def start
|
16
16
|
if @running.value
|
17
|
-
@config.logger.debug('
|
17
|
+
@config.logger.debug('feature_flags_worker already running.')
|
18
18
|
return
|
19
19
|
end
|
20
20
|
|
@@ -24,7 +24,7 @@ module SplitIoClient
|
|
24
24
|
|
25
25
|
def stop
|
26
26
|
unless @running.value
|
27
|
-
@config.logger.debug('
|
27
|
+
@config.logger.debug('feature_flags_worker not running.')
|
28
28
|
return
|
29
29
|
end
|
30
30
|
|
@@ -32,31 +32,63 @@ module SplitIoClient
|
|
32
32
|
SplitIoClient::Helpers::ThreadHelper.stop(:split_update_worker, @config)
|
33
33
|
end
|
34
34
|
|
35
|
-
def add_to_queue(
|
36
|
-
@config.logger.debug("
|
37
|
-
@queue.push(
|
35
|
+
def add_to_queue(notification)
|
36
|
+
@config.logger.debug("feature_flags_worker add to queue #{notification.data['changeNumber']}")
|
37
|
+
@queue.push(notification)
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
private
|
41
|
+
|
42
|
+
def update_feature_flag(notification)
|
43
|
+
return if @feature_flags_repository.get_change_number.to_i > notification.data['changeNumber']
|
42
44
|
|
43
|
-
@
|
44
|
-
|
45
|
-
|
45
|
+
if @feature_flags_repository.get_change_number == notification.data['pcn']
|
46
|
+
begin
|
47
|
+
@feature_flags_repository.add_split(
|
48
|
+
JSON.parse(
|
49
|
+
SplitIoClient::Helpers::DecryptionHelper.get_encoded_definition(
|
50
|
+
notification.data['c'],
|
51
|
+
notification.data['d']
|
52
|
+
),
|
53
|
+
symbolize_names: true
|
54
|
+
)
|
55
|
+
)
|
56
|
+
@feature_flags_repository.set_change_number(notification.data['changeNumber'])
|
57
|
+
return
|
58
|
+
rescue StandardError => e
|
59
|
+
@config.logger.debug("Failed to update Split: #{e.inspect}") if @config.debug_enabled
|
60
|
+
end
|
61
|
+
end
|
62
|
+
@synchronizer.fetch_splits(notification.data['changeNumber'])
|
46
63
|
end
|
47
64
|
|
48
|
-
|
65
|
+
def kill_feature_flag(notification)
|
66
|
+
return if @feature_flags_repository.get_change_number.to_i > notification.data['changeNumber']
|
67
|
+
|
68
|
+
@config.logger.debug("feature_flags_worker kill #{notification.data['splitName']}, #{notification.data['changeNumber']}")
|
69
|
+
@feature_flags_repository.kill(
|
70
|
+
notification.data['changeNumber'],
|
71
|
+
notification.data['splitName'],
|
72
|
+
notification.data['defaultTreatment']
|
73
|
+
)
|
74
|
+
@synchronizer.fetch_splits(notification.data['changeNumber'])
|
75
|
+
end
|
49
76
|
|
50
77
|
def perform
|
51
|
-
while (
|
52
|
-
@config.logger.debug("
|
53
|
-
|
78
|
+
while (notification = @queue.pop)
|
79
|
+
@config.logger.debug("feature_flags_worker change_number dequeue #{notification.data['changeNumber']}")
|
80
|
+
case notification.data['type']
|
81
|
+
when SSE::EventSource::EventTypes::SPLIT_UPDATE
|
82
|
+
update_feature_flag(notification)
|
83
|
+
when SSE::EventSource::EventTypes::SPLIT_KILL
|
84
|
+
kill_feature_flag(notification)
|
85
|
+
end
|
54
86
|
end
|
55
87
|
end
|
56
88
|
|
57
89
|
def perform_thread
|
58
90
|
@config.threads[:split_update_worker] = Thread.new do
|
59
|
-
@config.logger.debug('
|
91
|
+
@config.logger.debug('starting feature_flags_worker ...') if @config.debug_enabled
|
60
92
|
perform
|
61
93
|
end
|
62
94
|
end
|
@@ -156,7 +156,7 @@ module SplitIoClient
|
|
156
156
|
|
157
157
|
def valid_split_names?(method, split_names)
|
158
158
|
unless !split_names.nil? && split_names.is_a?(Array)
|
159
|
-
@config.logger.error("#{method}:
|
159
|
+
@config.logger.error("#{method}: feature_flag_names must be a non-empty Array")
|
160
160
|
return false
|
161
161
|
end
|
162
162
|
|
data/lib/splitclient-rb.rb
CHANGED
@@ -41,6 +41,7 @@ require 'splitclient-rb/cache/stores/store_utils'
|
|
41
41
|
require 'splitclient-rb/clients/split_client'
|
42
42
|
require 'splitclient-rb/managers/split_manager'
|
43
43
|
require 'splitclient-rb/helpers/thread_helper'
|
44
|
+
require 'splitclient-rb/helpers/decryption_helper'
|
44
45
|
require 'splitclient-rb/split_factory'
|
45
46
|
require 'splitclient-rb/split_factory_builder'
|
46
47
|
require 'splitclient-rb/split_config'
|
data/splitclient-rb.gemspec
CHANGED
@@ -48,6 +48,7 @@ Gem::Specification.new do |spec|
|
|
48
48
|
spec.add_development_dependency 'timecop', '~> 0.9'
|
49
49
|
spec.add_development_dependency 'webmock', '~> 3.14'
|
50
50
|
spec.add_development_dependency 'webrick', '~> 1.7'
|
51
|
+
spec.add_development_dependency 'byebug', '~> 11.1'
|
51
52
|
|
52
53
|
spec.add_runtime_dependency 'bitarray', '~> 1.3'
|
53
54
|
spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: splitclient-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.1.
|
4
|
+
version: 8.1.3.pre.rc1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Split Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,6 +192,20 @@ dependencies:
|
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '1.7'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
requirement: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - "~>"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '11.1'
|
201
|
+
name: byebug
|
202
|
+
prerelease: false
|
203
|
+
type: :development
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '11.1'
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
requirement: !ruby/object:Gem::Requirement
|
197
211
|
requirements:
|
@@ -498,6 +512,7 @@ files:
|
|
498
512
|
- lib/splitclient-rb/engine/sync_manager.rb
|
499
513
|
- lib/splitclient-rb/engine/synchronizer.rb
|
500
514
|
- lib/splitclient-rb/exceptions.rb
|
515
|
+
- lib/splitclient-rb/helpers/decryption_helper.rb
|
501
516
|
- lib/splitclient-rb/helpers/thread_helper.rb
|
502
517
|
- lib/splitclient-rb/managers/split_manager.rb
|
503
518
|
- lib/splitclient-rb/split_config.rb
|