determinator 2.5.1 → 2.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/determinator/control.rb +16 -6
- data/lib/determinator/feature.rb +8 -2
- data/lib/determinator/serializers/json.rb +1 -0
- data/lib/determinator/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acc3109dbf66955d32841b5fe5a56077e0e3b6f60bc0dfa39cb4318c2bb98ea8
|
4
|
+
data.tar.gz: f190ea639d1e0215045340be697d9493fd09bbe65c91072029b31f2ab3fcf20a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2fcd6ce6e7327d1d710ae0f1d2661da23d2b2407a919796c9a963aea1431889704641d7696842acb6076aab0be10176502056baf9c10ef5467ad41c937a8d5d
|
7
|
+
data.tar.gz: 1d2632f3df8056ca79870722efad6790ba8685ab618bc87b17cb33df4bfc773b82999f0b0af1644e3989ca9f6c19f229b35fe49a6890060e9fda5b3c8d4d68da
|
data/CHANGELOG.md
CHANGED
data/lib/determinator/control.rb
CHANGED
@@ -30,10 +30,11 @@ module Determinator
|
|
30
30
|
# @param :id [#to_s] The id of the actor being determinated for
|
31
31
|
# @param :guid [#to_s] The Anonymous id of the actor being determinated for
|
32
32
|
# @param :properties [Hash<Symbol,String>] The properties of this actor which will be used for including this actor or not
|
33
|
+
# @param :feature [Feature] The feature to use instead of retrieving one
|
33
34
|
# @raise [ArgumentError] When the arguments given to this method aren't ever going to produce a useful response
|
34
35
|
# @return [true,false] Whether the feature is on (true) or off (false) for this actor
|
35
|
-
def feature_flag_on?(name, id: nil, guid: nil, properties: {})
|
36
|
-
determinate_and_notice(name, id: id, guid: guid, properties: properties) do |feature|
|
36
|
+
def feature_flag_on?(name, id: nil, guid: nil, properties: {}, feature: nil)
|
37
|
+
determinate_and_notice(name, id: id, guid: guid, properties: properties, feature: feature) do |feature|
|
37
38
|
feature.feature_flag?
|
38
39
|
end
|
39
40
|
end
|
@@ -44,10 +45,11 @@ module Determinator
|
|
44
45
|
# @param :id [#to_s] The id of the actor being determinated for
|
45
46
|
# @param :guid [#to_s] The Anonymous id of the actor being determinated for
|
46
47
|
# @param :properties [Hash<Symbol,String>] The properties of this actor which will be used for including this actor or not
|
48
|
+
# @param :feature [Feature] The feature to use instead of retrieving one
|
47
49
|
# @raise [ArgumentError] When the arguments given to this method aren't ever going to produce a useful response
|
48
50
|
# @return [false,String] Returns false, if the actor is not in this experiment, or otherwise the variant name.
|
49
|
-
def which_variant(name, id: nil, guid: nil, properties: {})
|
50
|
-
determinate_and_notice(name, id: id, guid: guid, properties: properties) do |feature|
|
51
|
+
def which_variant(name, id: nil, guid: nil, properties: {}, feature: nil)
|
52
|
+
determinate_and_notice(name, id: id, guid: guid, properties: properties, feature: feature) do |feature|
|
51
53
|
feature.experiment?
|
52
54
|
end
|
53
55
|
end
|
@@ -58,6 +60,14 @@ module Determinator
|
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
63
|
+
# Uses the retrieval (and a cache if set on the Determinator config) to fetch a feature definition.
|
64
|
+
#
|
65
|
+
# @param name [#to_s] The name of the experiment being checked
|
66
|
+
# @return [Feature, MissingResponse] Returns the Feature object, or MissingResponse if the feature is not found.
|
67
|
+
def retrieve(name)
|
68
|
+
Determinator.with_retrieval_cache(name) { retrieval.retrieve(name) }
|
69
|
+
end
|
70
|
+
|
61
71
|
def inspect
|
62
72
|
'#<Determinator::Control>'
|
63
73
|
end
|
@@ -66,8 +76,8 @@ module Determinator
|
|
66
76
|
|
67
77
|
Indicators = Struct.new(:rollout, :variant)
|
68
78
|
|
69
|
-
def determinate_and_notice(name, id:, guid:, properties:)
|
70
|
-
feature
|
79
|
+
def determinate_and_notice(name, id:, guid:, properties:, feature: nil)
|
80
|
+
feature ||= retrieve(name)
|
71
81
|
|
72
82
|
if feature.nil? || feature.is_a?(ErrorResponse) || feature.is_a?(MissingResponse)
|
73
83
|
Determinator.notice_missing_feature(name)
|
data/lib/determinator/feature.rb
CHANGED
@@ -3,9 +3,9 @@ module Determinator
|
|
3
3
|
#
|
4
4
|
# @attr_reader [nil,Hash<String,Integer>] variants The variants for this experiment, with the name of the variant as the key and the weight as the value. Will be nil for non-experiments.
|
5
5
|
class Feature
|
6
|
-
attr_reader :name, :identifier, :bucket_type, :variants, :target_groups, :fixed_determinations, :active, :winning_variant
|
6
|
+
attr_reader :name, :identifier, :bucket_type, :structured_bucket, :variants, :target_groups, :fixed_determinations, :active, :winning_variant
|
7
7
|
|
8
|
-
def initialize(name:, identifier:, bucket_type:, target_groups:, fixed_determinations: [], variants: {}, overrides: {}, active: false, winning_variant: nil)
|
8
|
+
def initialize(name:, identifier:, bucket_type:, target_groups:, structured_bucket: nil, fixed_determinations: [], variants: {}, overrides: {}, active: false, winning_variant: nil)
|
9
9
|
@name = name.to_s
|
10
10
|
@identifier = identifier.to_s
|
11
11
|
@variants = variants
|
@@ -14,6 +14,7 @@ module Determinator
|
|
14
14
|
@winning_variant = parse_outcome(winning_variant, allow_exclusion: false)
|
15
15
|
@active = active
|
16
16
|
@bucket_type = bucket_type.to_sym
|
17
|
+
@structured_bucket = structured_bucket
|
17
18
|
|
18
19
|
# To prevent confusion between actor id data types
|
19
20
|
@overrides = overrides.each_with_object({}) do |(identifier, outcome), hash|
|
@@ -36,6 +37,11 @@ module Determinator
|
|
36
37
|
variants.empty?
|
37
38
|
end
|
38
39
|
|
40
|
+
# @return [true,false] Is this feature using structured identification?
|
41
|
+
def structured?
|
42
|
+
!!structured_bucket && !structured_bucket.empty?
|
43
|
+
end
|
44
|
+
|
39
45
|
# Is this feature overridden for the given actor id?
|
40
46
|
#
|
41
47
|
# @return [true,false] Whether this feature is overridden for this actor
|
@@ -15,6 +15,7 @@ module Determinator
|
|
15
15
|
name: obj['name'],
|
16
16
|
identifier: obj['identifier'],
|
17
17
|
bucket_type: obj['bucket_type'],
|
18
|
+
structured_bucket: obj['structured_bucket'],
|
18
19
|
active: (obj['active'] === true),
|
19
20
|
target_groups: obj['target_groups'],
|
20
21
|
fixed_determinations: obj['fixed_determinations'].to_a,
|
data/lib/determinator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: determinator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Hastings-Spital
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
-
description:
|
153
|
+
description:
|
154
154
|
email:
|
155
155
|
- jp@deliveroo.co.uk
|
156
156
|
executables: []
|
@@ -234,7 +234,7 @@ homepage: https://github.com/deliveroo/determinator
|
|
234
234
|
licenses:
|
235
235
|
- MIT
|
236
236
|
metadata: {}
|
237
|
-
post_install_message:
|
237
|
+
post_install_message:
|
238
238
|
rdoc_options: []
|
239
239
|
require_paths:
|
240
240
|
- lib
|
@@ -249,8 +249,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '0'
|
251
251
|
requirements: []
|
252
|
-
rubygems_version: 3.0.
|
253
|
-
signing_key:
|
252
|
+
rubygems_version: 3.0.3
|
253
|
+
signing_key:
|
254
254
|
specification_version: 4
|
255
255
|
summary: Determine which experiments and features a specific actor should see.
|
256
256
|
test_files: []
|