prefab-cloud-ruby 0.6.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.tool-versions +1 -0
- data/CODEOWNERS +1 -0
- data/Gemfile +7 -3
- data/Gemfile.lock +46 -11
- data/README.md +10 -1
- data/VERSION +1 -1
- data/compile_protos.sh +3 -0
- data/lib/prefab/client.rb +16 -7
- data/lib/prefab/config_client.rb +57 -20
- data/lib/prefab/config_helper.rb +20 -0
- data/lib/prefab/config_loader.rb +13 -11
- data/lib/prefab/config_resolver.rb +37 -41
- data/lib/prefab/feature_flag_client.rb +100 -11
- data/lib/prefab-cloud-ruby.rb +3 -0
- data/lib/prefab_pb.rb +201 -132
- data/lib/prefab_services_pb.rb +6 -6
- data/prefab-cloud-ruby.gemspec +31 -29
- data/run_test_harness_server.sh +2 -0
- data/test/harness_server.rb +51 -0
- data/test/test_config_loader.rb +20 -20
- data/test/test_config_resolver.rb +119 -37
- data/test/test_feature_flag_client.rb +191 -35
- data/test/test_helper.rb +18 -3
- metadata +77 -18
- data/.ruby-version +0 -1
@@ -1,6 +1,8 @@
|
|
1
1
|
module Prefab
|
2
2
|
class FeatureFlagClient
|
3
|
+
include Prefab::ConfigHelper
|
3
4
|
MAX_32_FLOAT = 4294967294.0
|
5
|
+
DISTRIBUTION_SPACE = 1000
|
4
6
|
|
5
7
|
def initialize(base_client)
|
6
8
|
@base_client = base_client
|
@@ -14,38 +16,125 @@ module Prefab
|
|
14
16
|
feature_is_on_for?(feature_name, nil)
|
15
17
|
end
|
16
18
|
|
17
|
-
def feature_is_on_for?(feature_name, lookup_key, attributes:
|
19
|
+
def feature_is_on_for?(feature_name, lookup_key, attributes: {})
|
18
20
|
@base_client.stats.increment("prefab.featureflag.on", tags: ["feature:#{feature_name}"])
|
19
21
|
|
22
|
+
return is_on?(get(feature_name, lookup_key, attributes))
|
23
|
+
end
|
24
|
+
|
25
|
+
def get(feature_name, lookup_key, attributes)
|
20
26
|
feature_obj = @base_client.config_client.get(feature_name)
|
21
|
-
|
27
|
+
variants = @base_client.config_client.get_config_obj(feature_name).variants
|
28
|
+
evaluate(feature_name, lookup_key, attributes, feature_obj, variants)
|
29
|
+
end
|
30
|
+
|
31
|
+
def evaluate(feature_name, lookup_key, attributes, feature_obj, variants)
|
32
|
+
value_of(get_variant(feature_name, lookup_key, attributes, feature_obj, variants))
|
22
33
|
end
|
23
34
|
|
24
35
|
private
|
25
36
|
|
26
|
-
def is_on?(
|
27
|
-
if
|
37
|
+
def is_on?(variant)
|
38
|
+
if variant.nil?
|
28
39
|
return false
|
29
40
|
end
|
41
|
+
variant.bool
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_variant(feature_name, lookup_key, attributes, feature_obj, variants)
|
45
|
+
if !feature_obj.active
|
46
|
+
return get_variant_obj(variants, feature_obj.inactive_variant_idx)
|
47
|
+
end
|
48
|
+
|
49
|
+
variant_distribution = feature_obj.default
|
50
|
+
|
51
|
+
# if user_targets.match
|
52
|
+
feature_obj.user_targets.each do |target|
|
53
|
+
if (target.identifiers.include? lookup_key)
|
54
|
+
return get_variant_obj(variants, target.variant_idx)
|
55
|
+
end
|
56
|
+
end
|
30
57
|
|
31
|
-
|
32
|
-
|
33
|
-
|
58
|
+
# if rules.match
|
59
|
+
feature_obj.rules.each do |rule|
|
60
|
+
if criteria_match?(rule, lookup_key, attributes)
|
61
|
+
variant_distribution = rule.distribution
|
62
|
+
end
|
34
63
|
end
|
35
64
|
|
36
|
-
if
|
37
|
-
|
65
|
+
if variant_distribution.type == :variant_idx
|
66
|
+
variant_idx = variant_distribution.variant_idx
|
67
|
+
else
|
68
|
+
percent_through_distribution = rand()
|
69
|
+
if lookup_key
|
70
|
+
percent_through_distribution = get_user_pct(feature_name, lookup_key)
|
71
|
+
end
|
72
|
+
distribution_bucket = DISTRIBUTION_SPACE * percent_through_distribution
|
73
|
+
|
74
|
+
variant_idx = get_variant_idx_from_weights(variant_distribution.variant_weights.weights, distribution_bucket, feature_name)
|
38
75
|
end
|
39
76
|
|
40
|
-
return
|
77
|
+
return get_variant_obj(variants, variant_idx)
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_variant_obj(variants, idx)
|
81
|
+
return variants[idx] if variants.length >= idx
|
82
|
+
nil
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_variant_idx_from_weights(variant_weights, bucket, feature_name)
|
86
|
+
sum = 0
|
87
|
+
variant_weights.each do |variant_weight|
|
88
|
+
if bucket < sum + variant_weight.weight
|
89
|
+
return variant_weight.variant_idx
|
90
|
+
else
|
91
|
+
sum += variant_weight.weight
|
92
|
+
end
|
93
|
+
end
|
94
|
+
# variants didn't add up to 100%
|
95
|
+
@base_client.log.info("Variants of #{feature_name} did not add to 100%")
|
96
|
+
return variant_weights.last.variant
|
41
97
|
end
|
42
98
|
|
43
99
|
def get_user_pct(feature, lookup_key)
|
44
|
-
to_hash = "#{@base_client.
|
100
|
+
to_hash = "#{@base_client.project_id}#{feature}#{lookup_key}"
|
45
101
|
int_value = Murmur3.murmur3_32(to_hash)
|
46
102
|
int_value / MAX_32_FLOAT
|
47
103
|
end
|
48
104
|
|
105
|
+
def criteria_match?(rule, lookup_key, attributes)
|
106
|
+
if rule.criteria.operator == :IN
|
107
|
+
return rule.criteria.values.include?(lookup_key)
|
108
|
+
elsif rule.criteria.operator == :NOT_IN
|
109
|
+
return !rule.criteria.values.include?(lookup_key)
|
110
|
+
elsif rule.criteria.operator == :IN_SEG
|
111
|
+
return segment_matches(rule.criteria.values, lookup_key, attributes).any?
|
112
|
+
elsif rule.criteria.operator == :NOT_IN_SEG
|
113
|
+
return segment_matches(rule.criteria.values, lookup_key, attributes).none?
|
114
|
+
end
|
115
|
+
@base_client.log.info("Unknown Operator")
|
116
|
+
false
|
117
|
+
end
|
118
|
+
|
119
|
+
# evaluate each segment key and return whether each one matches
|
120
|
+
# there should be an associated segment available as a standard config obj
|
121
|
+
def segment_matches(segment_keys, lookup_key, attributes)
|
122
|
+
segment_keys.map do |segment_key|
|
123
|
+
segment = @base_client.config_client.get(segment_key)
|
124
|
+
if segment.nil?
|
125
|
+
@base_client.log.info("Missing Segment")
|
126
|
+
false
|
127
|
+
else
|
128
|
+
segment_match?(segment, lookup_key, attributes)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def segment_match?(segment, lookup_key, attributes)
|
134
|
+
includes = segment.includes.include?(lookup_key)
|
135
|
+
excludes = segment.excludes.include?(lookup_key)
|
136
|
+
includes && !excludes
|
137
|
+
end
|
49
138
|
end
|
50
139
|
end
|
51
140
|
|
data/lib/prefab-cloud-ruby.rb
CHANGED
@@ -2,8 +2,11 @@ require "concurrent/atomics"
|
|
2
2
|
require 'concurrent'
|
3
3
|
require 'faraday'
|
4
4
|
require 'openssl'
|
5
|
+
require 'openssl'
|
6
|
+
require 'ld-eventsource'
|
5
7
|
require 'prefab_pb'
|
6
8
|
require 'prefab_services_pb'
|
9
|
+
require 'prefab/config_helper'
|
7
10
|
require 'prefab/config_loader'
|
8
11
|
require 'prefab/config_resolver'
|
9
12
|
require 'prefab/client'
|
data/lib/prefab_pb.rb
CHANGED
@@ -4,141 +4,210 @@
|
|
4
4
|
require 'google/protobuf'
|
5
5
|
|
6
6
|
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
7
|
+
add_file("prefab.proto", :syntax => :proto3) do
|
8
|
+
add_message "prefab.ConfigServicePointer" do
|
9
|
+
optional :project_id, :int64, 1
|
10
|
+
optional :start_at_id, :int64, 2
|
11
|
+
optional :env_key, :string, 3
|
12
|
+
end
|
13
|
+
add_message "prefab.ConfigValue" do
|
14
|
+
oneof :type do
|
15
|
+
optional :int, :int64, 1
|
16
|
+
optional :string, :string, 2
|
17
|
+
optional :bytes, :bytes, 3
|
18
|
+
optional :double, :double, 4
|
19
|
+
optional :bool, :bool, 5
|
20
|
+
optional :feature_flag, :message, 6, "prefab.FeatureFlag"
|
21
|
+
optional :limit_definition, :message, 7, "prefab.LimitDefinition"
|
22
|
+
optional :segment, :message, 8, "prefab.Segment"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
add_message "prefab.Configs" do
|
26
|
+
repeated :configs, :message, 1, "prefab.Config"
|
27
|
+
end
|
28
|
+
add_message "prefab.Config" do
|
29
|
+
optional :id, :int64, 1
|
30
|
+
optional :project_id, :int64, 2
|
31
|
+
optional :key, :string, 3
|
32
|
+
optional :changed_by, :string, 4
|
33
|
+
repeated :rows, :message, 5, "prefab.ConfigRow"
|
34
|
+
repeated :variants, :message, 6, "prefab.FeatureFlagVariant"
|
35
|
+
end
|
36
|
+
add_message "prefab.ConfigRow" do
|
37
|
+
optional :env_key, :string, 1
|
38
|
+
optional :namespace, :string, 2
|
39
|
+
optional :value, :message, 3, "prefab.ConfigValue"
|
40
|
+
end
|
41
|
+
add_message "prefab.LimitResponse" do
|
42
|
+
optional :passed, :bool, 1
|
43
|
+
optional :expires_at, :int64, 2
|
44
|
+
optional :enforced_group, :string, 3
|
45
|
+
optional :current_bucket, :int64, 4
|
46
|
+
optional :policy_group, :string, 5
|
47
|
+
optional :policy_name, :enum, 6, "prefab.LimitResponse.LimitPolicyNames"
|
48
|
+
optional :policy_limit, :int32, 7
|
49
|
+
optional :amount, :int64, 8
|
50
|
+
optional :limit_reset_at, :int64, 9
|
51
|
+
optional :safety_level, :enum, 10, "prefab.LimitDefinition.SafetyLevel"
|
52
|
+
end
|
53
|
+
add_enum "prefab.LimitResponse.LimitPolicyNames" do
|
54
|
+
value :NOT_SET, 0
|
55
|
+
value :SECONDLY_ROLLING, 1
|
56
|
+
value :MINUTELY_ROLLING, 3
|
57
|
+
value :HOURLY_ROLLING, 5
|
58
|
+
value :DAILY_ROLLING, 7
|
59
|
+
value :MONTHLY_ROLLING, 8
|
60
|
+
value :INFINITE, 9
|
61
|
+
value :YEARLY_ROLLING, 10
|
62
|
+
end
|
63
|
+
add_message "prefab.LimitRequest" do
|
64
|
+
optional :account_id, :int64, 1
|
65
|
+
optional :acquire_amount, :int32, 2
|
66
|
+
repeated :groups, :string, 3
|
67
|
+
optional :limit_combiner, :enum, 4, "prefab.LimitRequest.LimitCombiner"
|
68
|
+
optional :allow_partial_response, :bool, 5
|
69
|
+
optional :safety_level, :enum, 6, "prefab.LimitDefinition.SafetyLevel"
|
70
|
+
end
|
71
|
+
add_enum "prefab.LimitRequest.LimitCombiner" do
|
72
|
+
value :NOT_SET, 0
|
73
|
+
value :MINIMUM, 1
|
74
|
+
value :MAXIMUM, 2
|
75
|
+
end
|
76
|
+
add_message "prefab.FeatureFlagVariant" do
|
77
|
+
optional :name, :string, 5
|
78
|
+
optional :description, :string, 6
|
79
|
+
oneof :type do
|
80
|
+
optional :int, :int64, 1
|
81
|
+
optional :string, :string, 2
|
82
|
+
optional :double, :double, 3
|
83
|
+
optional :bool, :bool, 4
|
84
|
+
end
|
85
|
+
end
|
86
|
+
add_message "prefab.Criteria" do
|
87
|
+
optional :property, :string, 1
|
88
|
+
optional :operator, :enum, 2, "prefab.Criteria.CriteriaOperator"
|
89
|
+
repeated :values, :string, 3
|
90
|
+
end
|
91
|
+
add_enum "prefab.Criteria.CriteriaOperator" do
|
92
|
+
value :NOT_SET, 0
|
93
|
+
value :IN, 1
|
94
|
+
value :NOT_IN, 2
|
95
|
+
value :EQ, 3
|
96
|
+
value :IN_SEG, 4
|
97
|
+
value :NOT_IN_SEG, 5
|
98
|
+
end
|
99
|
+
add_message "prefab.Rule" do
|
100
|
+
optional :criteria, :message, 1, "prefab.Criteria"
|
101
|
+
optional :distribution, :message, 2, "prefab.VariantDistribution"
|
102
|
+
end
|
103
|
+
add_message "prefab.Segment" do
|
104
|
+
optional :name, :string, 1
|
105
|
+
optional :description, :string, 2
|
106
|
+
repeated :includes, :string, 3
|
107
|
+
repeated :excludes, :string, 4
|
108
|
+
repeated :criterion, :message, 5, "prefab.Criteria"
|
109
|
+
end
|
110
|
+
add_message "prefab.UserTarget" do
|
111
|
+
optional :variant_idx, :int32, 1
|
112
|
+
repeated :identifiers, :string, 2
|
113
|
+
end
|
114
|
+
add_message "prefab.VariantWeight" do
|
115
|
+
optional :weight, :int32, 1
|
116
|
+
optional :variant_idx, :int32, 2
|
117
|
+
end
|
118
|
+
add_message "prefab.VariantWeights" do
|
119
|
+
repeated :weights, :message, 1, "prefab.VariantWeight"
|
120
|
+
end
|
121
|
+
add_message "prefab.VariantDistribution" do
|
122
|
+
oneof :type do
|
123
|
+
optional :variant_idx, :int32, 1
|
124
|
+
optional :variant_weights, :message, 2, "prefab.VariantWeights"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
add_message "prefab.FeatureFlag" do
|
128
|
+
optional :active, :bool, 1
|
129
|
+
optional :inactive_variant_idx, :int32, 2
|
130
|
+
optional :default, :message, 3, "prefab.VariantDistribution"
|
131
|
+
repeated :user_targets, :message, 4, "prefab.UserTarget"
|
132
|
+
repeated :rules, :message, 5, "prefab.Rule"
|
133
|
+
end
|
134
|
+
add_message "prefab.LimitDefinition" do
|
135
|
+
optional :policy_name, :enum, 2, "prefab.LimitResponse.LimitPolicyNames"
|
136
|
+
optional :limit, :int32, 3
|
137
|
+
optional :burst, :int32, 4
|
138
|
+
optional :account_id, :int64, 5
|
139
|
+
optional :last_modified, :int64, 6
|
140
|
+
optional :returnable, :bool, 7
|
141
|
+
optional :safety_level, :enum, 8, "prefab.LimitDefinition.SafetyLevel"
|
142
|
+
end
|
143
|
+
add_enum "prefab.LimitDefinition.SafetyLevel" do
|
144
|
+
value :NOT_SET, 0
|
145
|
+
value :L4_BEST_EFFORT, 4
|
146
|
+
value :L5_BOMBPROOF, 5
|
147
|
+
end
|
148
|
+
add_message "prefab.LimitDefinitions" do
|
149
|
+
repeated :definitions, :message, 1, "prefab.LimitDefinition"
|
150
|
+
end
|
151
|
+
add_message "prefab.BufferedRequest" do
|
152
|
+
optional :account_id, :int64, 1
|
153
|
+
optional :method, :string, 2
|
154
|
+
optional :uri, :string, 3
|
155
|
+
optional :body, :string, 4
|
156
|
+
repeated :limit_groups, :string, 5
|
157
|
+
optional :content_type, :string, 6
|
158
|
+
optional :fifo, :bool, 7
|
159
|
+
end
|
160
|
+
add_message "prefab.BatchRequest" do
|
161
|
+
optional :account_id, :int64, 1
|
162
|
+
optional :method, :string, 2
|
163
|
+
optional :uri, :string, 3
|
164
|
+
optional :body, :string, 4
|
165
|
+
repeated :limit_groups, :string, 5
|
166
|
+
optional :batch_template, :string, 6
|
167
|
+
optional :batch_separator, :string, 7
|
168
|
+
end
|
169
|
+
add_message "prefab.BasicResponse" do
|
170
|
+
optional :message, :string, 1
|
171
|
+
end
|
172
|
+
add_message "prefab.CreationResponse" do
|
173
|
+
optional :message, :string, 1
|
174
|
+
optional :new_id, :int64, 2
|
175
|
+
end
|
176
|
+
add_enum "prefab.OnFailure" do
|
177
|
+
value :NOT_SET, 0
|
178
|
+
value :LOG_AND_PASS, 1
|
179
|
+
value :LOG_AND_FAIL, 2
|
180
|
+
value :THROW, 3
|
26
181
|
end
|
27
|
-
end
|
28
|
-
add_message "prefab.ConfigDeltas" do
|
29
|
-
repeated :deltas, :message, 1, "prefab.ConfigDelta"
|
30
|
-
end
|
31
|
-
add_message "prefab.UpsertRequest" do
|
32
|
-
optional :account_id, :int64, 1
|
33
|
-
optional :config_delta, :message, 2, "prefab.ConfigDelta"
|
34
|
-
optional :changed_by, :string, 4
|
35
|
-
end
|
36
|
-
add_message "prefab.LimitResponse" do
|
37
|
-
optional :passed, :bool, 1
|
38
|
-
optional :expires_at, :int64, 2
|
39
|
-
optional :enforced_group, :string, 3
|
40
|
-
optional :current_bucket, :int64, 4
|
41
|
-
optional :policy_group, :string, 5
|
42
|
-
optional :policy_name, :enum, 6, "prefab.LimitResponse.LimitPolicyNames"
|
43
|
-
optional :policy_limit, :int32, 7
|
44
|
-
optional :amount, :int64, 8
|
45
|
-
optional :limit_reset_at, :int64, 9
|
46
|
-
optional :safety_level, :enum, 10, "prefab.LimitDefinition.SafetyLevel"
|
47
|
-
end
|
48
|
-
add_enum "prefab.LimitResponse.LimitPolicyNames" do
|
49
|
-
value :NOT_SET, 0
|
50
|
-
value :SECONDLY_ROLLING, 1
|
51
|
-
value :MINUTELY_ROLLING, 3
|
52
|
-
value :HOURLY_ROLLING, 5
|
53
|
-
value :DAILY_ROLLING, 7
|
54
|
-
value :MONTHLY_ROLLING, 8
|
55
|
-
value :INFINITE, 9
|
56
|
-
value :YEARLY_ROLLING, 10
|
57
|
-
end
|
58
|
-
add_message "prefab.LimitRequest" do
|
59
|
-
optional :account_id, :int64, 1
|
60
|
-
optional :acquire_amount, :int32, 2
|
61
|
-
repeated :groups, :string, 3
|
62
|
-
optional :limit_combiner, :enum, 4, "prefab.LimitRequest.LimitCombiner"
|
63
|
-
optional :allow_partial_response, :bool, 5
|
64
|
-
optional :safety_level, :enum, 6, "prefab.LimitDefinition.SafetyLevel"
|
65
|
-
end
|
66
|
-
add_enum "prefab.LimitRequest.LimitCombiner" do
|
67
|
-
value :NOT_SET, 0
|
68
|
-
value :MINIMUM, 1
|
69
|
-
value :MAXIMUM, 2
|
70
|
-
end
|
71
|
-
add_message "prefab.FeatureFlag" do
|
72
|
-
optional :pct, :double, 3
|
73
|
-
repeated :whitelisted, :string, 4
|
74
|
-
end
|
75
|
-
add_message "prefab.LimitDefinition" do
|
76
|
-
optional :policy_name, :enum, 2, "prefab.LimitResponse.LimitPolicyNames"
|
77
|
-
optional :limit, :int32, 3
|
78
|
-
optional :burst, :int32, 4
|
79
|
-
optional :account_id, :int64, 5
|
80
|
-
optional :last_modified, :int64, 6
|
81
|
-
optional :returnable, :bool, 7
|
82
|
-
optional :safety_level, :enum, 8, "prefab.LimitDefinition.SafetyLevel"
|
83
|
-
end
|
84
|
-
add_enum "prefab.LimitDefinition.SafetyLevel" do
|
85
|
-
value :NOT_SET, 0
|
86
|
-
value :L4_BEST_EFFORT, 4
|
87
|
-
value :L5_BOMBPROOF, 5
|
88
|
-
end
|
89
|
-
add_message "prefab.LimitDefinitions" do
|
90
|
-
repeated :definitions, :message, 1, "prefab.LimitDefinition"
|
91
|
-
end
|
92
|
-
add_message "prefab.FeatureFlags" do
|
93
|
-
repeated :flags, :message, 1, "prefab.FeatureFlag"
|
94
|
-
optional :cache_expiry, :int64, 2
|
95
|
-
end
|
96
|
-
add_message "prefab.BufferedRequest" do
|
97
|
-
optional :account_id, :int64, 1
|
98
|
-
optional :method, :string, 2
|
99
|
-
optional :uri, :string, 3
|
100
|
-
optional :body, :string, 4
|
101
|
-
repeated :limit_groups, :string, 5
|
102
|
-
optional :content_type, :string, 6
|
103
|
-
optional :fifo, :bool, 7
|
104
|
-
end
|
105
|
-
add_message "prefab.BatchRequest" do
|
106
|
-
optional :account_id, :int64, 1
|
107
|
-
optional :method, :string, 2
|
108
|
-
optional :uri, :string, 3
|
109
|
-
optional :body, :string, 4
|
110
|
-
repeated :limit_groups, :string, 5
|
111
|
-
optional :batch_template, :string, 6
|
112
|
-
optional :batch_separator, :string, 7
|
113
|
-
end
|
114
|
-
add_message "prefab.BasicResponse" do
|
115
|
-
optional :message, :string, 1
|
116
|
-
end
|
117
|
-
add_enum "prefab.OnFailure" do
|
118
|
-
value :NOT_SET, 0
|
119
|
-
value :LOG_AND_PASS, 1
|
120
|
-
value :LOG_AND_FAIL, 2
|
121
|
-
value :THROW, 3
|
122
182
|
end
|
123
183
|
end
|
124
184
|
|
125
185
|
module Prefab
|
126
|
-
ConfigServicePointer = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ConfigServicePointer").msgclass
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
LimitResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitResponse").msgclass
|
132
|
-
LimitResponse::LimitPolicyNames = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitResponse.LimitPolicyNames").enummodule
|
133
|
-
LimitRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitRequest").msgclass
|
134
|
-
LimitRequest::LimitCombiner = Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitRequest.LimitCombiner").enummodule
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
186
|
+
ConfigServicePointer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ConfigServicePointer").msgclass
|
187
|
+
ConfigValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ConfigValue").msgclass
|
188
|
+
Configs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Configs").msgclass
|
189
|
+
Config = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Config").msgclass
|
190
|
+
ConfigRow = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ConfigRow").msgclass
|
191
|
+
LimitResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitResponse").msgclass
|
192
|
+
LimitResponse::LimitPolicyNames = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitResponse.LimitPolicyNames").enummodule
|
193
|
+
LimitRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitRequest").msgclass
|
194
|
+
LimitRequest::LimitCombiner = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitRequest.LimitCombiner").enummodule
|
195
|
+
FeatureFlagVariant = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.FeatureFlagVariant").msgclass
|
196
|
+
Criteria = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Criteria").msgclass
|
197
|
+
Criteria::CriteriaOperator = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Criteria.CriteriaOperator").enummodule
|
198
|
+
Rule = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Rule").msgclass
|
199
|
+
Segment = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Segment").msgclass
|
200
|
+
UserTarget = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.UserTarget").msgclass
|
201
|
+
VariantWeight = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.VariantWeight").msgclass
|
202
|
+
VariantWeights = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.VariantWeights").msgclass
|
203
|
+
VariantDistribution = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.VariantDistribution").msgclass
|
204
|
+
FeatureFlag = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.FeatureFlag").msgclass
|
205
|
+
LimitDefinition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitDefinition").msgclass
|
206
|
+
LimitDefinition::SafetyLevel = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitDefinition.SafetyLevel").enummodule
|
207
|
+
LimitDefinitions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitDefinitions").msgclass
|
208
|
+
BufferedRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.BufferedRequest").msgclass
|
209
|
+
BatchRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.BatchRequest").msgclass
|
210
|
+
BasicResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.BasicResponse").msgclass
|
211
|
+
CreationResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.CreationResponse").msgclass
|
212
|
+
OnFailure = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.OnFailure").enummodule
|
144
213
|
end
|
data/lib/prefab_services_pb.rb
CHANGED
@@ -8,13 +8,13 @@ module Prefab
|
|
8
8
|
module RateLimitService
|
9
9
|
class Service
|
10
10
|
|
11
|
-
include GRPC::GenericService
|
11
|
+
include ::GRPC::GenericService
|
12
12
|
|
13
13
|
self.marshal_class_method = :encode
|
14
14
|
self.unmarshal_class_method = :decode
|
15
15
|
self.service_name = 'prefab.RateLimitService'
|
16
16
|
|
17
|
-
rpc :LimitCheck, LimitRequest, LimitResponse
|
17
|
+
rpc :LimitCheck, ::Prefab::LimitRequest, ::Prefab::LimitResponse
|
18
18
|
end
|
19
19
|
|
20
20
|
Stub = Service.rpc_stub_class
|
@@ -22,15 +22,15 @@ module Prefab
|
|
22
22
|
module ConfigService
|
23
23
|
class Service
|
24
24
|
|
25
|
-
include GRPC::GenericService
|
25
|
+
include ::GRPC::GenericService
|
26
26
|
|
27
27
|
self.marshal_class_method = :encode
|
28
28
|
self.unmarshal_class_method = :decode
|
29
29
|
self.service_name = 'prefab.ConfigService'
|
30
30
|
|
31
|
-
rpc :GetConfig, ConfigServicePointer, stream(
|
32
|
-
rpc :GetAllConfig, ConfigServicePointer,
|
33
|
-
rpc :Upsert,
|
31
|
+
rpc :GetConfig, ::Prefab::ConfigServicePointer, stream(::Prefab::Configs)
|
32
|
+
rpc :GetAllConfig, ::Prefab::ConfigServicePointer, ::Prefab::Configs
|
33
|
+
rpc :Upsert, ::Prefab::Config, ::Prefab::CreationResponse
|
34
34
|
end
|
35
35
|
|
36
36
|
Stub = Service.rpc_stub_class
|
data/prefab-cloud-ruby.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: prefab-cloud-ruby 0.
|
5
|
+
# stub: prefab-cloud-ruby 0.9.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "prefab-cloud-ruby".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.9.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Jeff Dwyer".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2022-03-18"
|
15
15
|
s.description = "RateLimits & Config as a service".freeze
|
16
16
|
s.email = "jdwyer@prefab.cloud".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -20,7 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".envrc",
|
23
|
-
".
|
23
|
+
".tool-versions",
|
24
|
+
"CODEOWNERS",
|
24
25
|
"Gemfile",
|
25
26
|
"Gemfile.lock",
|
26
27
|
"LICENSE.txt",
|
@@ -33,6 +34,7 @@ Gem::Specification.new do |s|
|
|
33
34
|
"lib/prefab/cancellable_interceptor.rb",
|
34
35
|
"lib/prefab/client.rb",
|
35
36
|
"lib/prefab/config_client.rb",
|
37
|
+
"lib/prefab/config_helper.rb",
|
36
38
|
"lib/prefab/config_loader.rb",
|
37
39
|
"lib/prefab/config_resolver.rb",
|
38
40
|
"lib/prefab/feature_flag_client.rb",
|
@@ -44,7 +46,9 @@ Gem::Specification.new do |s|
|
|
44
46
|
"lib/prefab_pb.rb",
|
45
47
|
"lib/prefab_services_pb.rb",
|
46
48
|
"prefab-cloud-ruby.gemspec",
|
49
|
+
"run_test_harness_server.sh",
|
47
50
|
"test/.prefab.test.config.yaml",
|
51
|
+
"test/harness_server.rb",
|
48
52
|
"test/test_config_loader.rb",
|
49
53
|
"test/test_config_resolver.rb",
|
50
54
|
"test/test_feature_flag_client.rb",
|
@@ -53,43 +57,41 @@ Gem::Specification.new do |s|
|
|
53
57
|
]
|
54
58
|
s.homepage = "http://github.com/prefab-cloud/prefab-cloud-ruby".freeze
|
55
59
|
s.licenses = ["MIT".freeze]
|
56
|
-
s.rubygems_version = "2.
|
60
|
+
s.rubygems_version = "3.2.32".freeze
|
57
61
|
s.summary = "Prefab Ruby Infrastructure".freeze
|
58
62
|
|
59
63
|
if s.respond_to? :specification_version then
|
60
64
|
s.specification_version = 4
|
65
|
+
end
|
61
66
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
s.add_dependency(%q<grpc-tools>.freeze, ["~> 1.17.1"])
|
77
|
-
s.add_dependency(%q<shoulda>.freeze, [">= 0"])
|
78
|
-
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
79
|
-
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
80
|
-
s.add_dependency(%q<juwelier>.freeze, ["~> 2.4.9"])
|
81
|
-
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
82
|
-
end
|
67
|
+
if s.respond_to? :add_runtime_dependency then
|
68
|
+
s.add_runtime_dependency(%q<concurrent-ruby>.freeze, ["~> 1.0", ">= 1.0.5"])
|
69
|
+
s.add_runtime_dependency(%q<faraday>.freeze, [">= 0"])
|
70
|
+
s.add_runtime_dependency(%q<ld-eventsource>.freeze, [">= 0"])
|
71
|
+
s.add_runtime_dependency(%q<grpc>.freeze, [">= 0"])
|
72
|
+
s.add_runtime_dependency(%q<google-protobuf>.freeze, [">= 0"])
|
73
|
+
s.add_runtime_dependency(%q<googleapis-common-protos-types>.freeze, [">= 0"])
|
74
|
+
s.add_development_dependency(%q<grpc-tools>.freeze, [">= 0"])
|
75
|
+
s.add_development_dependency(%q<shoulda>.freeze, [">= 0"])
|
76
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
77
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
|
78
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.4.9"])
|
79
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
80
|
+
s.add_development_dependency(%q<thin>.freeze, [">= 0"])
|
83
81
|
else
|
84
|
-
s.add_dependency(%q<concurrent-ruby>.freeze, ["
|
82
|
+
s.add_dependency(%q<concurrent-ruby>.freeze, ["~> 1.0", ">= 1.0.5"])
|
85
83
|
s.add_dependency(%q<faraday>.freeze, [">= 0"])
|
84
|
+
s.add_dependency(%q<ld-eventsource>.freeze, [">= 0"])
|
86
85
|
s.add_dependency(%q<grpc>.freeze, [">= 0"])
|
87
|
-
s.add_dependency(%q<
|
86
|
+
s.add_dependency(%q<google-protobuf>.freeze, [">= 0"])
|
87
|
+
s.add_dependency(%q<googleapis-common-protos-types>.freeze, [">= 0"])
|
88
|
+
s.add_dependency(%q<grpc-tools>.freeze, [">= 0"])
|
88
89
|
s.add_dependency(%q<shoulda>.freeze, [">= 0"])
|
89
90
|
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
90
|
-
s.add_dependency(%q<bundler>.freeze, ["
|
91
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
91
92
|
s.add_dependency(%q<juwelier>.freeze, ["~> 2.4.9"])
|
92
93
|
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
94
|
+
s.add_dependency(%q<thin>.freeze, [">= 0"])
|
93
95
|
end
|
94
96
|
end
|
95
97
|
|
@@ -0,0 +1,2 @@
|
|
1
|
+
PREFAB_LOG_CLIENT_BOOTSTRAP_LOG_LEVEL=debug PREFAB_CLOUD_HTTP=true PREFAB_GRPC_URL="localhost:50051" ruby -Ilib test/harness_server.rb
|
2
|
+
#GRPC_TRACE=all GRPC_VERBOSITY=DEBUG PREFAB_LOG_CLIENT_BOOTSTRAP_LOG_LEVEL=debug PREFAB_CLOUD_HTTP=true PREFAB_API_KEY="1|local_development_api_key" PREFAB_API_URL="localhost:50051" ruby -Ilib test/harness_server.rb
|