unleash 5.1.1 → 6.0.0
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/.github/workflows/pull_request.yml +0 -2
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +10 -0
- data/README.md +93 -119
- data/lib/unleash/client.rb +21 -22
- data/lib/unleash/configuration.rb +2 -2
- data/lib/unleash/context.rb +35 -9
- data/lib/unleash/metrics_reporter.rb +12 -26
- data/lib/unleash/strategies.rb +14 -73
- data/lib/unleash/toggle_fetcher.rb +22 -56
- data/lib/unleash/variant.rb +6 -0
- data/lib/unleash/version.rb +1 -1
- data/lib/unleash.rb +1 -1
- data/unleash-client.gemspec +2 -2
- data/v6_MIGRATION_GUIDE.md +21 -0
- metadata +11 -26
- data/lib/unleash/activation_strategy.rb +0 -44
- data/lib/unleash/constraint.rb +0 -117
- data/lib/unleash/feature_toggle.rb +0 -253
- data/lib/unleash/metrics.rb +0 -41
- data/lib/unleash/strategy/application_hostname.rb +0 -26
- data/lib/unleash/strategy/base.rb +0 -16
- data/lib/unleash/strategy/default.rb +0 -13
- data/lib/unleash/strategy/flexible_rollout.rb +0 -64
- data/lib/unleash/strategy/gradual_rollout_random.rb +0 -24
- data/lib/unleash/strategy/gradual_rollout_sessionid.rb +0 -21
- data/lib/unleash/strategy/gradual_rollout_userid.rb +0 -21
- data/lib/unleash/strategy/remote_address.rb +0 -36
- data/lib/unleash/strategy/user_with_id.rb +0 -20
- data/lib/unleash/strategy/util.rb +0 -17
- data/lib/unleash/variant_definition.rb +0 -26
- data/lib/unleash/variant_override.rb +0 -44
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'unleash/variant_override'
|
2
|
-
|
3
|
-
module Unleash
|
4
|
-
class VariantDefinition
|
5
|
-
attr_accessor :name, :weight, :payload, :overrides, :stickiness
|
6
|
-
|
7
|
-
def initialize(name, weight = 0, payload = nil, stickiness = nil, overrides = []) # rubocop:disable Metrics/ParameterLists
|
8
|
-
self.name = name
|
9
|
-
self.weight = weight
|
10
|
-
self.payload = payload
|
11
|
-
self.stickiness = stickiness
|
12
|
-
self.overrides = (overrides || [])
|
13
|
-
.select{ |v| v.is_a?(Hash) && v.has_key?('contextName') }
|
14
|
-
.map{ |v| VariantOverride.new(v.fetch('contextName', ''), v.fetch('values', [])) } || []
|
15
|
-
end
|
16
|
-
|
17
|
-
def override_matches_context?(context)
|
18
|
-
self.overrides.select{ |o| o.matches_context?(context) }.first
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_s
|
22
|
-
"<VariantDefinition: name=#{self.name},weight=#{self.weight},payload=#{self.payload},stickiness=#{self.stickiness}" \
|
23
|
-
",overrides=#{self.overrides}>"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module Unleash
|
2
|
-
class VariantOverride
|
3
|
-
attr_accessor :context_name, :values
|
4
|
-
|
5
|
-
def initialize(context_name, values = [])
|
6
|
-
self.context_name = context_name
|
7
|
-
self.values = values || []
|
8
|
-
|
9
|
-
validate
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_s
|
13
|
-
"<VariantOverride: context_name=#{self.context_name},values=#{self.values}>"
|
14
|
-
end
|
15
|
-
|
16
|
-
def matches_context?(context)
|
17
|
-
raise ArgumentError, 'context must be of class Unleash::Context' unless context.instance_of?(Unleash::Context)
|
18
|
-
|
19
|
-
context_value =
|
20
|
-
case self.context_name
|
21
|
-
when 'userId'
|
22
|
-
context.user_id
|
23
|
-
when 'sessionId'
|
24
|
-
context.session_id
|
25
|
-
when 'remoteAddress'
|
26
|
-
context.remote_address
|
27
|
-
else
|
28
|
-
context.properties.fetch(self.context_name, nil)
|
29
|
-
end
|
30
|
-
|
31
|
-
Unleash.logger.debug "VariantOverride: context_name: #{context_name} context_value: #{context_value}"
|
32
|
-
|
33
|
-
self.values.include? context_value.to_s
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def validate
|
39
|
-
raise ArgumentError, 'context_name must be a String' unless self.context_name.is_a?(String)
|
40
|
-
raise ArgumentError, 'values must be an Array of strings' unless self.values.is_a?(Array) \
|
41
|
-
&& self.values.reject{ |v| v.is_a?(String) }.empty?
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|