Skip to content

Commit cb9e20b

Browse files
authored
Merge pull request #470 from splitio/development
[8.1.2] Development into Main
2 parents 0ebba8d + 4929d40 commit cb9e20b

15 files changed

Lines changed: 96 additions & 75 deletions

File tree

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
CHANGES
22

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 IntelliSense comments.
5+
36
8.1.1 (Mar 17, 2023)
47
- Added retries with backoff when the sdk tries to connect to the Streaming service and it is not available.
58
- Updated the way that the sdk write mtks in redis.

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Split SDK for Ruby
2-
![Build Status](https://github.com/splitio/ruby-client/actions/workflows/ci.yml/badge.svg?branch=master)
2+
[![build status](https://github.com/splitio/ruby-client/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/splitio/ruby-client/actions)
3+
[![Documentation](https://img.shields.io/badge/ruby_client-documentation-informational)](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
34

45
## Overview
5-
This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via a Split feature flag to manage your complete customer experience.
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.
67

78
[![Twitter Follow](https://img.shields.io/twitter/follow/splitsoftware.svg?style=social&label=Follow&maxAge=1529000)](https://twitter.com/intent/follow?screen_name=splitsoftware)
89

@@ -21,7 +22,7 @@ Below is a simple example that describes the instantiation and most basic usage
2122
```ruby
2223
require 'splitclient-rb'
2324

24-
split_factory = SplitIoClient::SplitFactory.new('SDK_API_KEY')
25+
split_factory = SplitIoClient::SplitFactory.new('YOUR_SDK_KEY')
2526
split_client = split_factory.client
2627

2728
begin
@@ -30,7 +31,7 @@ rescue SplitIoClient::SDKBlockerTimeoutExpiredException
3031
puts 'SDK is not ready. Decide whether to continue or abort execution'
3132
end
3233

33-
treatment = split_client.get_treatment('CUSTOMER_ID', 'SPLIT_NAME');
34+
treatment = split_client.get_treatment('CUSTOMER_ID', 'FEATURE_FLAG_NAME');
3435

3536
if treatment == 'on'
3637
# 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
6061

6162
Split has built and maintains SDKs for:
6263

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)
6369
* Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
64-
* Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
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)
6572
* 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)
6873
* PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
6974
* Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
70-
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
71-
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
72-
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
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)
7379

7480
For a comprehensive list of open source projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).
7581

lib/splitclient-rb/cache/fetchers/split_fetcher.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def stop_splits_thread
4949

5050
def splits_thread
5151
@config.threads[:split_fetcher] = Thread.new do
52-
@config.logger.info('Starting splits fetcher service') if @config.debug_enabled
52+
@config.logger.info('Starting feature flags fetcher service') if @config.debug_enabled
5353
loop do
5454
fetch_splits
5555

5656
sleep_for = SplitIoClient::Cache::Stores::StoreUtils.random_interval(@config.features_refresh_rate)
57-
@config.logger.debug("Splits fetcher is sleeping for: #{sleep_for} seconds") if @config.debug_enabled
57+
@config.logger.debug("Feature flags fetcher is sleeping for: #{sleep_for} seconds") if @config.debug_enabled
5858
sleep(sleep_for)
5959
end
6060
end
@@ -66,7 +66,7 @@ def splits_since(since, fetch_options = { cache_control_headers: false, till: ni
6666

6767
def add_split_unless_archived(split)
6868
if Engine::Models::Split.archived?(split)
69-
@config.logger.debug("Seeing archived split #{split[:name]}") if @config.debug_enabled
69+
@config.logger.debug("Seeing archived feature flag #{split[:name]}") if @config.debug_enabled
7070

7171
remove_archived_split(split)
7272
else
@@ -75,13 +75,13 @@ def add_split_unless_archived(split)
7575
end
7676

7777
def remove_archived_split(split)
78-
@config.logger.debug("removing split from store(#{split})") if @config.debug_enabled
78+
@config.logger.debug("removing feature flag from store(#{split})") if @config.debug_enabled
7979

8080
@splits_repository.remove_split(split)
8181
end
8282

8383
def store_split(split)
84-
@config.logger.debug("storing split (#{split[:name]})") if @config.debug_enabled
84+
@config.logger.debug("storing feature flag (#{split[:name]})") if @config.debug_enabled
8585

8686
@splits_repository.add_split(split)
8787
end

lib/splitclient-rb/cache/stores/localhost_split_store.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def call
3131

3232
def splits_thread
3333
@config.threads[:split_store] = Thread.new do
34-
@config.logger.info('Starting splits fetcher service')
34+
@config.logger.info('Starting feature flags fetcher service')
3535
loop do
3636
store_splits
3737

@@ -53,7 +53,7 @@ def store_splits
5353
end
5454

5555
def store_split(split)
56-
@config.logger.debug("storing split (#{split[:name]})") if @config.debug_enabled
56+
@config.logger.debug("storing feature flag (#{split[:name]})") if @config.debug_enabled
5757

5858
@splits_repository.add_split(split)
5959
end

lib/splitclient-rb/clients/split_client.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class SplitClient
1111
#
1212
# Creates a new split client instance that connects to split.io API.
1313
#
14-
# @param api_key [String] the API key for your split account
14+
# @param sdk_key [String] the SDK key for your split account
1515
#
1616
# @return [SplitIoClient] split.io client instance
17-
def initialize(api_key, repositories, status_manager, config, impressions_manager, telemetry_evaluation_producer)
18-
@api_key = api_key
17+
def initialize(sdk_key, repositories, status_manager, config, impressions_manager, telemetry_evaluation_producer)
18+
@api_key = sdk_key
1919
@splits_repository = repositories[:splits]
2020
@segments_repository = repositories[:segments]
2121
@impressions_repository = repositories[:impressions]
@@ -103,8 +103,8 @@ def track(key, traffic_type_name, event_type, value = nil, properties = nil)
103103

104104
if ready? && !@config.localhost_mode && !@splits_repository.traffic_type_exists(traffic_type_name)
105105
@config.logger.warn("track: Traffic Type #{traffic_type_name} " \
106-
"does not have any corresponding Splits in this environment, make sure you're tracking " \
107-
'your events to a valid traffic type defined in the Split console')
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')
108108
end
109109

110110
@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 @@ def sanitize_split_names(calling_method, split_names)
147147
if (split_name.is_a?(String) || split_name.is_a?(Symbol)) && !split_name.empty?
148148
true
149149
elsif split_name.is_a?(String) && split_name.empty?
150-
@config.logger.warn("#{calling_method}: you passed an empty split_name, split_name must be a non-empty String or a Symbol")
150+
@config.logger.warn("#{calling_method}: you passed an empty feature_flag_name, flag name must be a non-empty String or a Symbol")
151151
false
152152
else
153-
@config.logger.warn("#{calling_method}: you passed an invalid split_name, split_name must be a non-empty String or a Symbol")
153+
@config.logger.warn("#{calling_method}: you passed an invalid feature_flag_name, flag name must be a non-empty String or a Symbol")
154154
false
155155
end
156156
end
@@ -200,7 +200,7 @@ def treatments(key, split_names, attributes = {}, calling_method = 'get_treatmen
200200
sanitized_split_names = sanitize_split_names(calling_method, split_names)
201201

202202
if sanitized_split_names.empty?
203-
@config.logger.error("#{calling_method}: split_names must be a non-empty Array")
203+
@config.logger.error("#{calling_method}: feature_flag_names must be a non-empty Array")
204204
return {}
205205
end
206206

@@ -258,7 +258,7 @@ def treatment(
258258
sanitized_split_name = split_name.to_s.strip
259259

260260
if split_name.to_s != sanitized_split_name
261-
@config.logger.warn("#{calling_method}: split_name #{split_name} has extra whitespace, trimming")
261+
@config.logger.warn("#{calling_method}: feature_flag_name #{split_name} has extra whitespace, trimming")
262262
split_name = sanitized_split_name
263263
end
264264

@@ -271,7 +271,7 @@ def treatment(
271271

272272
if split.nil? && ready?
273273
@config.logger.warn("#{calling_method}: you passed #{split_name} that " \
274-
'does not exist in this environment, please double check what Splits exist in the web console')
274+
'does not exist in this environment, please double check what feature flags exist in the Split user interface')
275275

276276
return parsed_treatment(multiple, control_treatment.merge({ label: Engine::Models::Label::NOT_FOUND }))
277277
end

lib/splitclient-rb/engine/api/splits.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def since(since, fetch_options = { cache_control_headers: false, till: nil })
2020
result = splits_with_segment_names(response.body)
2121

2222
unless result[:splits].empty?
23-
@config.split_logger.log_if_debug("#{result[:splits].length} splits retrieved. since=#{since}")
23+
@config.split_logger.log_if_debug("#{result[:splits].length} feature flags retrieved. since=#{since}")
2424
end
25-
@config.split_logger.log_if_transport("Split changes response: #{result.to_s}")
25+
@config.split_logger.log_if_transport("Feature flag changes response: #{result.to_s}")
2626

2727
bucket = BinarySearchLatencyTracker.get_bucket((Time.now - start) * 1000.0)
2828
@telemetry_runtime_producer.record_sync_latency(Telemetry::Domain::Constants::SPLIT_SYNC, bucket)
@@ -32,10 +32,10 @@ def since(since, fetch_options = { cache_control_headers: false, till: nil })
3232
else
3333
@telemetry_runtime_producer.record_sync_error(Telemetry::Domain::Constants::SPLIT_SYNC, response.status)
3434

35-
@config.logger.error("Unexpected status code while fetching splits: #{response.status}. " \
35+
@config.logger.error("Unexpected status code while fetching feature flags: #{response.status}. " \
3636
'Check your API key and base URI')
3737

38-
raise 'Split SDK failed to connect to backend to fetch split definitions'
38+
raise 'Split SDK failed to connect to backend to fetch feature flags definitions'
3939
end
4040
end
4141

lib/splitclient-rb/engine/matchers/dependency_matcher.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ module SplitIoClient
44
class DependencyMatcher
55
MATCHER_TYPE = 'IN_SPLIT_TREATMENT'
66

7-
def initialize(split, treatments, logger)
8-
@split = split
7+
def initialize(feature_flag, treatments, logger)
8+
@feature_flag = feature_flag
99
@treatments = treatments
1010
@logger = logger
1111
end
1212

1313
def match?(args)
1414
keys = { matching_key: args[:matching_key], bucketing_key: args[:bucketing_key] }
15-
evaluate = args[:evaluator].call(keys, @split, args[:attributes])
15+
evaluate = args[:evaluator].call(keys, @feature_flag, args[:attributes])
1616
matches = @treatments.include?(evaluate[:treatment])
17-
@logger.log_if_debug("[dependencyMatcher] Parent split #{@split} evaluated to #{evaluate[:treatment]} \
18-
with label #{evaluate[:label]}. #{@split} evaluated treatment is part of [#{@treatments}] ? #{matches}.")
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}.")
1919
matches
2020
end
2121

lib/splitclient-rb/engine/synchronizer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def sync_result(success, remaining_attempts, segment_names = nil)
201201
end
202202

203203
def sync_splits_and_segments
204-
@config.logger.debug('Synchronizing Splits and Segments ...') if @config.debug_enabled
204+
@config.logger.debug('Synchronizing feature flags and segments ...') if @config.debug_enabled
205205
splits_result = @split_fetcher.fetch_splits
206206

207207
splits_result[:success] && @segment_fetcher.fetch_segments

lib/splitclient-rb/managers/split_manager.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,31 @@ def split_names
5050
# method to get a split view
5151
#
5252
# @returns a split view
53-
def split(split_name)
54-
return unless @config.valid_mode && @splits_repository && @config.split_validator.valid_split_parameters(split_name)
53+
def split(feature_flag_name)
54+
return unless @config.valid_mode && @splits_repository && @config.split_validator.valid_split_parameters(feature_flag_name)
5555

5656
if !ready?
5757
@config.logger.error("split: the SDK is not ready, the operation cannot be executed")
5858
return
5959
end
6060

61-
sanitized_split_name= split_name.to_s.strip
61+
sanitized_feature_flag_name = feature_flag_name.to_s.strip
6262

63-
if split_name.to_s != sanitized_split_name
64-
@config.logger.warn("split: split_name #{split_name} has extra whitespace, trimming")
65-
split_name = sanitized_split_name
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
6666
end
6767

68-
split = @splits_repository.get_split(split_name)
68+
split = @splits_repository.get_split(feature_flag_name)
6969

7070
if ready? && split.nil?
71-
@config.logger.warn("split: you passed #{split_name} " \
72-
'that does not exist in this environment, please double check what Splits exist in the web console')
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')
7373
end
7474

7575
return if split.nil? || Engine::Models::Split.archived?(split)
7676

77-
build_split_view(split_name, split)
77+
build_split_view(feature_flag_name, split)
7878
end
7979

8080
def block_until_ready(time = nil)

lib/splitclient-rb/sse/workers/splits_worker.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def initialize(synchronizer, config, splits_repository)
1414

1515
def start
1616
if @running.value
17-
@config.logger.debug('splits worker already running.')
17+
@config.logger.debug('feature_flags_worker already running.')
1818
return
1919
end
2020

@@ -24,7 +24,7 @@ def start
2424

2525
def stop
2626
unless @running.value
27-
@config.logger.debug('splits worker not running.')
27+
@config.logger.debug('feature_flags_worker not running.')
2828
return
2929
end
3030

@@ -33,14 +33,14 @@ def stop
3333
end
3434

3535
def add_to_queue(change_number)
36-
@config.logger.debug("SplitsWorker add to queue #{change_number}")
36+
@config.logger.debug("feature_flags_worker add to queue #{change_number}")
3737
@queue.push(change_number)
3838
end
3939

4040
def kill_split(change_number, split_name, default_treatment)
4141
return if @splits_repository.get_change_number.to_i > change_number
4242

43-
@config.logger.debug("SplitsWorker kill #{split_name}, #{change_number}")
43+
@config.logger.debug("feature_flags_worker kill #{split_name}, #{change_number}")
4444
@splits_repository.kill(change_number, split_name, default_treatment)
4545
add_to_queue(change_number)
4646
end
@@ -49,14 +49,14 @@ def kill_split(change_number, split_name, default_treatment)
4949

5050
def perform
5151
while (change_number = @queue.pop)
52-
@config.logger.debug("SplitsWorker change_number dequeue #{change_number}")
52+
@config.logger.debug("feature_flags_worker change_number dequeue #{change_number}")
5353
@synchronizer.fetch_splits(change_number)
5454
end
5555
end
5656

5757
def perform_thread
5858
@config.threads[:split_update_worker] = Thread.new do
59-
@config.logger.debug('Starting splits worker ...') if @config.debug_enabled
59+
@config.logger.debug('starting feature_flags_worker ...') if @config.debug_enabled
6060
perform
6161
end
6262
end

0 commit comments

Comments
 (0)