Skip to content

Commit 0f5ac2f

Browse files
authored
Merge branch 'development' into Feature/Semver
2 parents a1cab94 + 6eafede commit 0f5ac2f

40 files changed

Lines changed: 397 additions & 258 deletions

CHANGES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
CHANGES
22

3-
Next release (TBD)
3+
8.3.1 (Mar 22, 2024)
44
- Fixed ruby process hanging due to failed thread.join command, when calling destroy and a http request still active.
5+
- Fixed streaming notification parser. Issue ref: https://github.com/splitio/ruby-client/issues/511
56

67
8.3.0 (Dec 11, 2023)
78
- Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation):

lib/splitclient-rb.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@
111111
require 'splitclient-rb/engine/synchronizer'
112112
require 'splitclient-rb/utilitites'
113113

114+
require 'splitclient-rb/spec.rb'
115+
114116
# SSE
115117
require 'splitclient-rb/sse/event_source/client'
116118
require 'splitclient-rb/sse/event_source/event_parser'

lib/splitclient-rb/cache/repositories/events/memory_repository.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ def clear
2929
@adapter.clear
3030
end
3131

32+
def empty?
33+
@adapter.empty?
34+
end
35+
3236
def batch
3337
return [] if @config.events_queue_size.zero?
3438

lib/splitclient-rb/cache/repositories/events_repository.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def post_events
2525
@config.log_found_exception(__method__.to_s, e)
2626
end
2727

28+
def empty?
29+
@repository.empty?
30+
end
31+
2832
protected
2933

3034
def metadata

lib/splitclient-rb/cache/repositories/splits_repository.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Cache
55
module Repositories
66
class SplitsRepository < Repository
77
attr_reader :adapter
8-
DEFAULT_CONDITIONS_TEMPLATE = {
8+
DEFAULT_CONDITIONS_TEMPLATE = [{
99
conditionType: "ROLLOUT",
1010
matcherGroup: {
1111
combiner: "AND",
@@ -30,7 +30,8 @@ class SplitsRepository < Repository
3030
}
3131
],
3232
label: "unsupported matcher type"
33-
}
33+
}]
34+
3435
def initialize(config, flag_sets_repository, flag_set_filter)
3536
super(config)
3637
@tt_cache = {}
@@ -182,7 +183,7 @@ def add_feature_flag(split)
182183

183184
if check_undefined_matcher(split)
184185
@config.logger.warn("Feature Flag #{split[:name]} has undefined matcher, setting conditions to default template.")
185-
split[:conditions] = [SplitsRepository::DEFAULT_CONDITIONS_TEMPLATE]
186+
split[:conditions] = SplitsRepository::DEFAULT_CONDITIONS_TEMPLATE
186187
end
187188
if !split[:sets].nil?
188189
for flag_set in split[:sets]

lib/splitclient-rb/clients/split_client.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,16 @@ def get_treatments_with_config_by_flag_sets(key, flag_sets, attributes = {})
9696

9797
def destroy
9898
@config.logger.info('Split client shutdown started...') if @config.debug_enabled
99-
99+
if !@config.cache_adapter.is_a?(SplitIoClient::Cache::Adapters::RedisAdapter) && @config.impressions_mode != :none &&
100+
(!@impressions_repository.empty? || !@events_repository.empty?)
101+
@config.logger.debug("Impressions and/or Events cache is not empty")
102+
# Adding small delay to ensure sender threads are fully running
103+
sleep(0.1)
104+
if !@config.threads.key?(:impressions_sender) || !@config.threads.key?(:events_sender)
105+
@config.logger.debug("Periodic data recording thread has not started yet, waiting for service startup.")
106+
@config.threads[:start_sdk].join(5) if @config.threads.key?(:start_sdk)
107+
end
108+
end
100109
@config.threads.select { |name, thread| name.to_s.end_with? 'sender' }.values.each do |thread|
101110
thread.raise(SplitIoClient::SDKShutdownException)
102111
thread.join

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def initialize(config)
1010
end
1111

1212
def get_api(url, api_key, params = {}, cache_control_headers = false)
13+
api_client.options.params_encoder.sort_params = false
1314
api_client.get(url, params) do |req|
1415
req.headers = common_headers(api_key).merge('Accept-Encoding' => 'gzip')
1516
req.headers = req.headers.merge('Cache-Control' => 'no-cache') if cache_control_headers
@@ -29,7 +30,7 @@ def post_api(url, api_key, data, headers = {}, params = {})
2930
req.headers = common_headers(api_key)
3031
.merge('Content-Type' => 'application/json')
3132
.merge(headers)
32-
33+
3334
machine_ip = @config.machine_ip
3435
machine_name = @config.machine_name
3536

@@ -55,6 +56,7 @@ def api_client
5556
@api_client ||= Faraday.new do |builder|
5657
builder.use SplitIoClient::FaradayMiddleware::Gzip
5758
builder.adapter :net_http_persistent
59+
builder.options.params_encoder = Faraday::FlatParamsEncoder
5860
end
5961
end
6062

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ module SplitIoClient
44
module Api
55
# Retrieves split definitions from the Split Backend
66
class Splits < Client
7+
78
def initialize(api_key, config, telemetry_runtime_producer)
89
super(config)
910
@api_key = api_key
1011
@telemetry_runtime_producer = telemetry_runtime_producer
1112
@flag_sets_filter = @config.flag_sets_filter
1213
end
1314

14-
def since(since, fetch_options = { cache_control_headers: false, till: nil, sets: nil })
15+
def since(since, fetch_options = { cache_control_headers: false, till: nil, sets: nil})
1516
start = Time.now
1617

17-
params = { since: since }
18+
params = { s: SplitIoClient::Spec::FeatureFlags::SPEC_VERSION, since: since }
1819
params[:till] = fetch_options[:till] unless fetch_options[:till].nil?
1920
params[:sets] = @flag_sets_filter.join(",") unless @flag_sets_filter.empty?
2021
@config.logger.debug("Fetching from splitChanges with #{params}: ")

lib/splitclient-rb/engine/auth_api_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def initialize(config, telemetry_runtime_producer)
1414

1515
def authenticate(api_key)
1616
start = Time.now
17-
response = @api_client.get_api(@config.auth_service_url, api_key)
17+
response = @api_client.get_api("#{@config.auth_service_url}?s=#{SplitIoClient::Spec::FeatureFlags::SPEC_VERSION}", api_key)
1818

1919
return process_success(response, start) if response.success?
2020

lib/splitclient-rb/spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module SplitIoClient
4+
module Spec
5+
class FeatureFlags
6+
SPEC_VERSION = "1.1"
7+
end
8+
end
9+
end

0 commit comments

Comments
 (0)