Skip to content

Commit

Permalink
Merge pull request #496 from splitio/SDKS-7638
Browse files Browse the repository at this point in the history
Adding default treatment in split view
  • Loading branch information
sanzmauro authored Nov 29, 2023
2 parents 7d21bb3 + f092fee commit 90f56b4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
CHANGES

x.x.x (coming soon)
- Added `default_treatment` property to the `split_view` object returned by the `split` and `splits` methods of the SDK manager.

8.2.0 (Jul 18, 2023)
- 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.

Expand Down
2 changes: 1 addition & 1 deletion lib/splitclient-rb/clients/split_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def treatment(
{ bucketing_key: bucketing_key, matching_key: matching_key }, split, attributes
)
else
@config.logger.error("#{calling_method}: the SDK is not ready, the operation cannot be executed")
@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.")

control_treatment.merge({ label: Engine::Models::Label::NOT_READY })
end
Expand Down
3 changes: 2 additions & 1 deletion lib/splitclient-rb/managers/split_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def build_split_view(name, split)
killed: split[:killed],
treatments: treatments,
change_number: split[:changeNumber],
configs: split[:configurations] || {}
configs: split[:configurations] || {},
default_treatment: split[:defaultTreatment]
}
end

Expand Down
2 changes: 1 addition & 1 deletion spec/engine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@

expect(subject.get_treatment('random_user_id', 'test_feature'))
.to eq SplitIoClient::Engine::Models::Treatment::CONTROL
expect(log.string).to include 'get_treatment: the SDK is not ready, the operation cannot be executed'
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'
end
end

Expand Down
6 changes: 6 additions & 0 deletions spec/splitclient/manager_localhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
let(:split_view) do
{ change_number: nil,
configs: { local_treatment: nil },
default_treatment: "control_treatment",
killed: false,
name: 'local_feature',
traffic_type_name: nil,
Expand All @@ -25,12 +26,14 @@
let(:split_views) do
[{ change_number: nil,
configs: { local_treatment: nil },
default_treatment: "control_treatment",
killed: false,
name: 'local_feature',
traffic_type_name: nil,
treatments: ['local_treatment'] },
{ change_number: nil,
configs: { local_treatment2: nil },
default_treatment: "control_treatment",
killed: false,
name: 'local_feature2',
traffic_type_name: nil,
Expand Down Expand Up @@ -59,6 +62,7 @@
on: '{"desc":"this applies only to ON and only for john_doe and jane_doe. The rest will receive OFF"}',
off: '{"desc":"this applies only to OFF treatment"}'
},
default_treatment: "control_treatment",
killed: false,
name: 'multiple_keys_feature',
traffic_type_name: nil,
Expand All @@ -68,6 +72,7 @@
on: '{"desc":"this applies only to ON and only for john_doe. The rest will receive OFF"}',
off: '{"desc":"this applies only to OFF treatment"}'
},
default_treatment: "control_treatment",
killed: false,
name: 'single_key_feature',
traffic_type_name: nil,
Expand All @@ -76,6 +81,7 @@
configs: {
off: '{"desc":"this applies only to OFF treatment"}'
},
default_treatment: "control_treatment",
killed: false,
name: 'no_keys_feature',
traffic_type_name: nil,
Expand Down

0 comments on commit 90f56b4

Please sign in to comment.