Skip to content

Commit 90f56b4

Browse files
authored
Merge pull request #496 from splitio/SDKS-7638
Adding default treatment in split view
2 parents 7d21bb3 + f092fee commit 90f56b4

5 files changed

Lines changed: 13 additions & 3 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+
x.x.x (coming soon)
4+
- Added `default_treatment` property to the `split_view` object returned by the `split` and `splits` methods of the SDK manager.
5+
36
8.2.0 (Jul 18, 2023)
47
- Improved streaming architecture implementation to apply feature flag updates from the notification received which is now enhanced, improving efficiency and reliability of the whole update system.
58

lib/splitclient-rb/clients/split_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def treatment(
282282
{ bucketing_key: bucketing_key, matching_key: matching_key }, split, attributes
283283
)
284284
else
285-
@config.logger.error("#{calling_method}: the SDK is not ready, the operation cannot be executed")
285+
@config.logger.error("#{calling_method}: the SDK is not ready, results may be incorrect for feature flag #{split_name}. Make sure to wait for SDK readiness before using this method.")
286286

287287
control_treatment.merge({ label: Engine::Models::Label::NOT_READY })
288288
end

lib/splitclient-rb/managers/split_manager.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def build_split_view(name, split)
105105
killed: split[:killed],
106106
treatments: treatments,
107107
change_number: split[:changeNumber],
108-
configs: split[:configurations] || {}
108+
configs: split[:configurations] || {},
109+
default_treatment: split[:defaultTreatment]
109110
}
110111
end
111112

spec/engine_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294

295295
expect(subject.get_treatment('random_user_id', 'test_feature'))
296296
.to eq SplitIoClient::Engine::Models::Treatment::CONTROL
297-
expect(log.string).to include 'get_treatment: the SDK is not ready, the operation cannot be executed'
297+
expect(log.string).to include 'get_treatment: the SDK is not ready, results may be incorrect for feature flag test_feature. Make sure to wait for SDK readiness before using this method'
298298
end
299299
end
300300

spec/splitclient/manager_localhost_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
let(:split_view) do
1717
{ change_number: nil,
1818
configs: { local_treatment: nil },
19+
default_treatment: "control_treatment",
1920
killed: false,
2021
name: 'local_feature',
2122
traffic_type_name: nil,
@@ -25,12 +26,14 @@
2526
let(:split_views) do
2627
[{ change_number: nil,
2728
configs: { local_treatment: nil },
29+
default_treatment: "control_treatment",
2830
killed: false,
2931
name: 'local_feature',
3032
traffic_type_name: nil,
3133
treatments: ['local_treatment'] },
3234
{ change_number: nil,
3335
configs: { local_treatment2: nil },
36+
default_treatment: "control_treatment",
3437
killed: false,
3538
name: 'local_feature2',
3639
traffic_type_name: nil,
@@ -59,6 +62,7 @@
5962
on: '{"desc":"this applies only to ON and only for john_doe and jane_doe. The rest will receive OFF"}',
6063
off: '{"desc":"this applies only to OFF treatment"}'
6164
},
65+
default_treatment: "control_treatment",
6266
killed: false,
6367
name: 'multiple_keys_feature',
6468
traffic_type_name: nil,
@@ -68,6 +72,7 @@
6872
on: '{"desc":"this applies only to ON and only for john_doe. The rest will receive OFF"}',
6973
off: '{"desc":"this applies only to OFF treatment"}'
7074
},
75+
default_treatment: "control_treatment",
7176
killed: false,
7277
name: 'single_key_feature',
7378
traffic_type_name: nil,
@@ -76,6 +81,7 @@
7681
configs: {
7782
off: '{"desc":"this applies only to OFF treatment"}'
7883
},
84+
default_treatment: "control_treatment",
7985
killed: false,
8086
name: 'no_keys_feature',
8187
traffic_type_name: nil,

0 commit comments

Comments
 (0)