prefab-cloud-ruby 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +39 -0
- data/.tool-versions +1 -0
- data/CODEOWNERS +1 -0
- data/Gemfile +11 -4
- data/Gemfile.lock +52 -32
- data/README.md +19 -1
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/compile_protos.sh +3 -0
- data/lib/prefab/auth_interceptor.rb +1 -0
- data/lib/prefab/cancellable_interceptor.rb +1 -0
- data/lib/prefab/client.rb +51 -38
- data/lib/prefab/config_client.rb +145 -73
- data/lib/prefab/config_helper.rb +29 -0
- data/lib/prefab/config_loader.rb +98 -13
- data/lib/prefab/config_resolver.rb +56 -49
- data/lib/prefab/error.rb +6 -0
- data/lib/prefab/errors/initialization_timeout_error.rb +13 -0
- data/lib/prefab/errors/invalid_api_key_error.rb +19 -0
- data/lib/prefab/errors/missing_default_error.rb +13 -0
- data/lib/prefab/feature_flag_client.rb +129 -11
- data/lib/prefab/internal_logger.rb +29 -0
- data/lib/prefab/logger_client.rb +10 -8
- data/lib/prefab/murmer3.rb +1 -0
- data/lib/prefab/noop_cache.rb +1 -0
- data/lib/prefab/noop_stats.rb +1 -0
- data/lib/prefab/options.rb +82 -0
- data/lib/prefab/ratelimit_client.rb +1 -0
- data/lib/prefab-cloud-ruby.rb +10 -0
- data/lib/prefab_pb.rb +214 -132
- data/lib/prefab_services_pb.rb +35 -6
- data/prefab-cloud-ruby.gemspec +29 -10
- data/run_test_harness_server.sh +8 -0
- data/test/.prefab.test.config.yaml +27 -1
- data/test/harness_server.rb +64 -0
- data/test/test_client.rb +98 -0
- data/test/test_config_client.rb +56 -0
- data/test/test_config_loader.rb +39 -25
- data/test/test_config_resolver.rb +134 -38
- data/test/test_feature_flag_client.rb +277 -35
- data/test/test_helper.rb +70 -4
- data/test/test_logger.rb +23 -29
- metadata +69 -14
- data/.ruby-version +0 -1
data/lib/prefab_pb.rb
CHANGED
@@ -1,144 +1,226 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
3
|
# source: prefab.proto
|
3
4
|
|
4
5
|
require 'google/protobuf'
|
5
6
|
|
6
7
|
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
|
-
|
8
|
+
add_file("prefab.proto", :syntax => :proto3) do
|
9
|
+
add_message "prefab.ConfigServicePointer" do
|
10
|
+
optional :project_id, :int64, 1
|
11
|
+
optional :start_at_id, :int64, 2
|
12
|
+
optional :project_env_id, :int64, 3
|
13
|
+
end
|
14
|
+
add_message "prefab.ConfigValue" do
|
15
|
+
oneof :type do
|
16
|
+
optional :int, :int64, 1
|
17
|
+
optional :string, :string, 2
|
18
|
+
optional :bytes, :bytes, 3
|
19
|
+
optional :double, :double, 4
|
20
|
+
optional :bool, :bool, 5
|
21
|
+
optional :feature_flag, :message, 6, "prefab.FeatureFlag"
|
22
|
+
optional :limit_definition, :message, 7, "prefab.LimitDefinition"
|
23
|
+
optional :segment, :message, 8, "prefab.Segment"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
add_message "prefab.Configs" do
|
27
|
+
repeated :configs, :message, 1, "prefab.Config"
|
28
|
+
optional :config_service_pointer, :message, 2, "prefab.ConfigServicePointer"
|
29
|
+
end
|
30
|
+
add_message "prefab.Config" do
|
31
|
+
optional :id, :int64, 1
|
32
|
+
optional :project_id, :int64, 2
|
33
|
+
optional :key, :string, 3
|
34
|
+
optional :changed_by, :string, 4
|
35
|
+
repeated :rows, :message, 5, "prefab.ConfigRow"
|
36
|
+
repeated :variants, :message, 6, "prefab.FeatureFlagVariant"
|
37
|
+
end
|
38
|
+
add_message "prefab.ConfigRow" do
|
39
|
+
optional :project_env_id, :int64, 1
|
40
|
+
optional :namespace, :string, 2
|
41
|
+
optional :value, :message, 3, "prefab.ConfigValue"
|
42
|
+
end
|
43
|
+
add_message "prefab.LimitResponse" do
|
44
|
+
optional :passed, :bool, 1
|
45
|
+
optional :expires_at, :int64, 2
|
46
|
+
optional :enforced_group, :string, 3
|
47
|
+
optional :current_bucket, :int64, 4
|
48
|
+
optional :policy_group, :string, 5
|
49
|
+
optional :policy_name, :enum, 6, "prefab.LimitResponse.LimitPolicyNames"
|
50
|
+
optional :policy_limit, :int32, 7
|
51
|
+
optional :amount, :int64, 8
|
52
|
+
optional :limit_reset_at, :int64, 9
|
53
|
+
optional :safety_level, :enum, 10, "prefab.LimitDefinition.SafetyLevel"
|
54
|
+
end
|
55
|
+
add_enum "prefab.LimitResponse.LimitPolicyNames" do
|
56
|
+
value :NOT_SET, 0
|
57
|
+
value :SECONDLY_ROLLING, 1
|
58
|
+
value :MINUTELY_ROLLING, 3
|
59
|
+
value :HOURLY_ROLLING, 5
|
60
|
+
value :DAILY_ROLLING, 7
|
61
|
+
value :MONTHLY_ROLLING, 8
|
62
|
+
value :INFINITE, 9
|
63
|
+
value :YEARLY_ROLLING, 10
|
64
|
+
end
|
65
|
+
add_message "prefab.LimitRequest" do
|
66
|
+
optional :account_id, :int64, 1
|
67
|
+
optional :acquire_amount, :int32, 2
|
68
|
+
repeated :groups, :string, 3
|
69
|
+
optional :limit_combiner, :enum, 4, "prefab.LimitRequest.LimitCombiner"
|
70
|
+
optional :allow_partial_response, :bool, 5
|
71
|
+
optional :safety_level, :enum, 6, "prefab.LimitDefinition.SafetyLevel"
|
72
|
+
end
|
73
|
+
add_enum "prefab.LimitRequest.LimitCombiner" do
|
74
|
+
value :NOT_SET, 0
|
75
|
+
value :MINIMUM, 1
|
76
|
+
value :MAXIMUM, 2
|
77
|
+
end
|
78
|
+
add_message "prefab.FeatureFlagVariant" do
|
79
|
+
proto3_optional :int, :int64, 1
|
80
|
+
proto3_optional :string, :string, 2
|
81
|
+
proto3_optional :double, :double, 3
|
82
|
+
proto3_optional :bool, :bool, 4
|
83
|
+
optional :name, :string, 5
|
84
|
+
optional :description, :string, 6
|
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 :LOOKUP_KEY_IN, 1
|
94
|
+
value :LOOKUP_KEY_NOT_IN, 2
|
95
|
+
value :IN_SEG, 3
|
96
|
+
value :NOT_IN_SEG, 4
|
97
|
+
value :ALWAYS_TRUE, 5
|
98
|
+
value :PROP_IS_ONE_OF, 6
|
99
|
+
value :PROP_IS_NOT_ONE_OF, 7
|
100
|
+
value :PROP_ENDS_WITH_ONE_OF, 8
|
101
|
+
value :PROP_DOES_NOT_END_WITH_ONE_OF, 9
|
102
|
+
end
|
103
|
+
add_message "prefab.Rule" do
|
104
|
+
optional :criteria, :message, 1, "prefab.Criteria"
|
105
|
+
repeated :variant_weights, :message, 2, "prefab.VariantWeight"
|
106
|
+
end
|
107
|
+
add_message "prefab.Segment" do
|
108
|
+
repeated :criterion, :message, 1, "prefab.Criteria"
|
109
|
+
end
|
110
|
+
add_message "prefab.VariantWeight" do
|
111
|
+
optional :weight, :int32, 1
|
112
|
+
optional :variant_idx, :int32, 2
|
113
|
+
end
|
114
|
+
add_message "prefab.FeatureFlag" do
|
115
|
+
optional :active, :bool, 1
|
116
|
+
optional :inactive_variant_idx, :int32, 2
|
117
|
+
repeated :rules, :message, 5, "prefab.Rule"
|
118
|
+
end
|
119
|
+
add_message "prefab.Identity" do
|
120
|
+
proto3_optional :lookup, :string, 1
|
121
|
+
map :attributes, :string, :string, 2
|
122
|
+
end
|
123
|
+
add_message "prefab.ClientConfigValue" do
|
124
|
+
proto3_optional :int, :int64, 1
|
125
|
+
proto3_optional :string, :string, 2
|
126
|
+
proto3_optional :double, :double, 3
|
127
|
+
proto3_optional :bool, :bool, 4
|
128
|
+
end
|
129
|
+
add_message "prefab.ConfigEvaluations" do
|
130
|
+
map :values, :string, :message, 1, "prefab.ClientConfigValue"
|
131
|
+
end
|
132
|
+
add_message "prefab.LimitDefinition" do
|
133
|
+
optional :policy_name, :enum, 2, "prefab.LimitResponse.LimitPolicyNames"
|
134
|
+
optional :limit, :int32, 3
|
135
|
+
optional :burst, :int32, 4
|
136
|
+
optional :account_id, :int64, 5
|
137
|
+
optional :last_modified, :int64, 6
|
138
|
+
optional :returnable, :bool, 7
|
139
|
+
optional :safety_level, :enum, 8, "prefab.LimitDefinition.SafetyLevel"
|
140
|
+
end
|
141
|
+
add_enum "prefab.LimitDefinition.SafetyLevel" do
|
142
|
+
value :NOT_SET, 0
|
143
|
+
value :L4_BEST_EFFORT, 4
|
144
|
+
value :L5_BOMBPROOF, 5
|
145
|
+
end
|
146
|
+
add_message "prefab.LimitDefinitions" do
|
147
|
+
repeated :definitions, :message, 1, "prefab.LimitDefinition"
|
148
|
+
end
|
149
|
+
add_message "prefab.BufferedRequest" do
|
150
|
+
optional :account_id, :int64, 1
|
151
|
+
optional :method, :string, 2
|
152
|
+
optional :uri, :string, 3
|
153
|
+
optional :body, :string, 4
|
154
|
+
repeated :limit_groups, :string, 5
|
155
|
+
optional :content_type, :string, 6
|
156
|
+
optional :fifo, :bool, 7
|
157
|
+
end
|
158
|
+
add_message "prefab.BatchRequest" do
|
159
|
+
optional :account_id, :int64, 1
|
160
|
+
optional :method, :string, 2
|
161
|
+
optional :uri, :string, 3
|
162
|
+
optional :body, :string, 4
|
163
|
+
repeated :limit_groups, :string, 5
|
164
|
+
optional :batch_template, :string, 6
|
165
|
+
optional :batch_separator, :string, 7
|
166
|
+
end
|
167
|
+
add_message "prefab.BasicResponse" do
|
168
|
+
optional :message, :string, 1
|
169
|
+
end
|
170
|
+
add_message "prefab.CreationResponse" do
|
171
|
+
optional :message, :string, 1
|
172
|
+
optional :new_id, :int64, 2
|
173
|
+
end
|
174
|
+
add_message "prefab.IdBlock" do
|
175
|
+
optional :project_id, :int64, 1
|
176
|
+
optional :project_env_id, :int64, 2
|
177
|
+
optional :sequence_name, :string, 3
|
178
|
+
optional :start, :int64, 4
|
179
|
+
optional :end, :int64, 5
|
180
|
+
end
|
181
|
+
add_message "prefab.IdBlockRequest" do
|
182
|
+
optional :project_id, :int64, 1
|
183
|
+
optional :project_env_id, :int64, 2
|
184
|
+
optional :sequence_name, :string, 3
|
185
|
+
optional :size, :int64, 4
|
186
|
+
end
|
187
|
+
add_enum "prefab.OnFailure" do
|
188
|
+
value :NOT_SET, 0
|
189
|
+
value :LOG_AND_PASS, 1
|
190
|
+
value :LOG_AND_FAIL, 2
|
191
|
+
value :THROW, 3
|
26
192
|
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
193
|
end
|
123
194
|
end
|
124
195
|
|
125
196
|
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
|
-
|
197
|
+
ConfigServicePointer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ConfigServicePointer").msgclass
|
198
|
+
ConfigValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ConfigValue").msgclass
|
199
|
+
Configs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Configs").msgclass
|
200
|
+
Config = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Config").msgclass
|
201
|
+
ConfigRow = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ConfigRow").msgclass
|
202
|
+
LimitResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitResponse").msgclass
|
203
|
+
LimitResponse::LimitPolicyNames = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitResponse.LimitPolicyNames").enummodule
|
204
|
+
LimitRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitRequest").msgclass
|
205
|
+
LimitRequest::LimitCombiner = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitRequest.LimitCombiner").enummodule
|
206
|
+
FeatureFlagVariant = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.FeatureFlagVariant").msgclass
|
207
|
+
Criteria = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Criteria").msgclass
|
208
|
+
Criteria::CriteriaOperator = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Criteria.CriteriaOperator").enummodule
|
209
|
+
Rule = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Rule").msgclass
|
210
|
+
Segment = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Segment").msgclass
|
211
|
+
VariantWeight = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.VariantWeight").msgclass
|
212
|
+
FeatureFlag = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.FeatureFlag").msgclass
|
213
|
+
Identity = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.Identity").msgclass
|
214
|
+
ClientConfigValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ClientConfigValue").msgclass
|
215
|
+
ConfigEvaluations = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.ConfigEvaluations").msgclass
|
216
|
+
LimitDefinition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitDefinition").msgclass
|
217
|
+
LimitDefinition::SafetyLevel = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitDefinition.SafetyLevel").enummodule
|
218
|
+
LimitDefinitions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.LimitDefinitions").msgclass
|
219
|
+
BufferedRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.BufferedRequest").msgclass
|
220
|
+
BatchRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.BatchRequest").msgclass
|
221
|
+
BasicResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.BasicResponse").msgclass
|
222
|
+
CreationResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.CreationResponse").msgclass
|
223
|
+
IdBlock = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.IdBlock").msgclass
|
224
|
+
IdBlockRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.IdBlockRequest").msgclass
|
225
|
+
OnFailure = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("prefab.OnFailure").enummodule
|
144
226
|
end
|
data/lib/prefab_services_pb.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
3
|
# Source: prefab.proto for package 'prefab'
|
3
4
|
|
@@ -8,13 +9,13 @@ module Prefab
|
|
8
9
|
module RateLimitService
|
9
10
|
class Service
|
10
11
|
|
11
|
-
include GRPC::GenericService
|
12
|
+
include ::GRPC::GenericService
|
12
13
|
|
13
14
|
self.marshal_class_method = :encode
|
14
15
|
self.unmarshal_class_method = :decode
|
15
16
|
self.service_name = 'prefab.RateLimitService'
|
16
17
|
|
17
|
-
rpc :LimitCheck, LimitRequest, LimitResponse
|
18
|
+
rpc :LimitCheck, ::Prefab::LimitRequest, ::Prefab::LimitResponse
|
18
19
|
end
|
19
20
|
|
20
21
|
Stub = Service.rpc_stub_class
|
@@ -22,15 +23,43 @@ module Prefab
|
|
22
23
|
module ConfigService
|
23
24
|
class Service
|
24
25
|
|
25
|
-
include GRPC::GenericService
|
26
|
+
include ::GRPC::GenericService
|
26
27
|
|
27
28
|
self.marshal_class_method = :encode
|
28
29
|
self.unmarshal_class_method = :decode
|
29
30
|
self.service_name = 'prefab.ConfigService'
|
30
31
|
|
31
|
-
rpc :GetConfig, ConfigServicePointer, stream(
|
32
|
-
rpc :GetAllConfig, ConfigServicePointer,
|
33
|
-
rpc :Upsert,
|
32
|
+
rpc :GetConfig, ::Prefab::ConfigServicePointer, stream(::Prefab::Configs)
|
33
|
+
rpc :GetAllConfig, ::Prefab::ConfigServicePointer, ::Prefab::Configs
|
34
|
+
rpc :Upsert, ::Prefab::Config, ::Prefab::CreationResponse
|
35
|
+
end
|
36
|
+
|
37
|
+
Stub = Service.rpc_stub_class
|
38
|
+
end
|
39
|
+
module IdService
|
40
|
+
class Service
|
41
|
+
|
42
|
+
include ::GRPC::GenericService
|
43
|
+
|
44
|
+
self.marshal_class_method = :encode
|
45
|
+
self.unmarshal_class_method = :decode
|
46
|
+
self.service_name = 'prefab.IdService'
|
47
|
+
|
48
|
+
rpc :GetBlock, ::Prefab::IdBlockRequest, ::Prefab::IdBlock
|
49
|
+
end
|
50
|
+
|
51
|
+
Stub = Service.rpc_stub_class
|
52
|
+
end
|
53
|
+
module ClientService
|
54
|
+
class Service
|
55
|
+
|
56
|
+
include ::GRPC::GenericService
|
57
|
+
|
58
|
+
self.marshal_class_method = :encode
|
59
|
+
self.unmarshal_class_method = :decode
|
60
|
+
self.service_name = 'prefab.ClientService'
|
61
|
+
|
62
|
+
rpc :GetAll, ::Prefab::Identity, ::Prefab::ConfigEvaluations
|
34
63
|
end
|
35
64
|
|
36
65
|
Stub = Service.rpc_stub_class
|
data/prefab-cloud-ruby.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.13.
|
5
|
+
# stub: prefab-cloud-ruby 0.13.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "prefab-cloud-ruby".freeze
|
9
|
-
s.version = "0.13.
|
9
|
+
s.version = "0.13.2"
|
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]
|
@@ -20,7 +20,9 @@ Gem::Specification.new do |s|
|
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".envrc",
|
23
|
-
".ruby
|
23
|
+
".github/workflows/ruby.yml",
|
24
|
+
".tool-versions",
|
25
|
+
"CODEOWNERS",
|
24
26
|
"Gemfile",
|
25
27
|
"Gemfile.lock",
|
26
28
|
"LICENSE.txt",
|
@@ -33,18 +35,29 @@ Gem::Specification.new do |s|
|
|
33
35
|
"lib/prefab/cancellable_interceptor.rb",
|
34
36
|
"lib/prefab/client.rb",
|
35
37
|
"lib/prefab/config_client.rb",
|
38
|
+
"lib/prefab/config_helper.rb",
|
36
39
|
"lib/prefab/config_loader.rb",
|
37
40
|
"lib/prefab/config_resolver.rb",
|
41
|
+
"lib/prefab/error.rb",
|
42
|
+
"lib/prefab/errors/initialization_timeout_error.rb",
|
43
|
+
"lib/prefab/errors/invalid_api_key_error.rb",
|
44
|
+
"lib/prefab/errors/missing_default_error.rb",
|
38
45
|
"lib/prefab/feature_flag_client.rb",
|
46
|
+
"lib/prefab/internal_logger.rb",
|
39
47
|
"lib/prefab/logger_client.rb",
|
40
48
|
"lib/prefab/murmer3.rb",
|
41
49
|
"lib/prefab/noop_cache.rb",
|
42
50
|
"lib/prefab/noop_stats.rb",
|
51
|
+
"lib/prefab/options.rb",
|
43
52
|
"lib/prefab/ratelimit_client.rb",
|
44
53
|
"lib/prefab_pb.rb",
|
45
54
|
"lib/prefab_services_pb.rb",
|
46
55
|
"prefab-cloud-ruby.gemspec",
|
56
|
+
"run_test_harness_server.sh",
|
47
57
|
"test/.prefab.test.config.yaml",
|
58
|
+
"test/harness_server.rb",
|
59
|
+
"test/test_client.rb",
|
60
|
+
"test/test_config_client.rb",
|
48
61
|
"test/test_config_loader.rb",
|
49
62
|
"test/test_config_resolver.rb",
|
50
63
|
"test/test_feature_flag_client.rb",
|
@@ -53,7 +66,7 @@ Gem::Specification.new do |s|
|
|
53
66
|
]
|
54
67
|
s.homepage = "http://github.com/prefab-cloud/prefab-cloud-ruby".freeze
|
55
68
|
s.licenses = ["MIT".freeze]
|
56
|
-
s.rubygems_version = "3.
|
69
|
+
s.rubygems_version = "3.2.32".freeze
|
57
70
|
s.summary = "Prefab Ruby Infrastructure".freeze
|
58
71
|
|
59
72
|
if s.respond_to? :specification_version then
|
@@ -63,23 +76,29 @@ Gem::Specification.new do |s|
|
|
63
76
|
if s.respond_to? :add_runtime_dependency then
|
64
77
|
s.add_runtime_dependency(%q<concurrent-ruby>.freeze, ["~> 1.0", ">= 1.0.5"])
|
65
78
|
s.add_runtime_dependency(%q<faraday>.freeze, [">= 0"])
|
79
|
+
s.add_runtime_dependency(%q<ld-eventsource>.freeze, [">= 0"])
|
66
80
|
s.add_runtime_dependency(%q<grpc>.freeze, [">= 0"])
|
67
|
-
s.
|
68
|
-
s.
|
81
|
+
s.add_runtime_dependency(%q<google-protobuf>.freeze, [">= 0"])
|
82
|
+
s.add_runtime_dependency(%q<googleapis-common-protos-types>.freeze, [">= 0"])
|
83
|
+
s.add_development_dependency(%q<grpc-tools>.freeze, [">= 0"])
|
69
84
|
s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
70
|
-
s.add_development_dependency(%q<bundler>.freeze, ["
|
85
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
|
71
86
|
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.4.9"])
|
72
87
|
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
88
|
+
s.add_development_dependency(%q<thin>.freeze, [">= 0"])
|
73
89
|
else
|
74
90
|
s.add_dependency(%q<concurrent-ruby>.freeze, ["~> 1.0", ">= 1.0.5"])
|
75
91
|
s.add_dependency(%q<faraday>.freeze, [">= 0"])
|
92
|
+
s.add_dependency(%q<ld-eventsource>.freeze, [">= 0"])
|
76
93
|
s.add_dependency(%q<grpc>.freeze, [">= 0"])
|
77
|
-
s.add_dependency(%q<
|
78
|
-
s.add_dependency(%q<
|
94
|
+
s.add_dependency(%q<google-protobuf>.freeze, [">= 0"])
|
95
|
+
s.add_dependency(%q<googleapis-common-protos-types>.freeze, [">= 0"])
|
96
|
+
s.add_dependency(%q<grpc-tools>.freeze, [">= 0"])
|
79
97
|
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
80
|
-
s.add_dependency(%q<bundler>.freeze, ["
|
98
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
81
99
|
s.add_dependency(%q<juwelier>.freeze, ["~> 2.4.9"])
|
82
100
|
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
101
|
+
s.add_dependency(%q<thin>.freeze, [">= 0"])
|
83
102
|
end
|
84
103
|
end
|
85
104
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
#! /usr/bin/env bash
|
2
|
+
|
3
|
+
PREFAB_CDN_URL="https://api-prefab-cloud.global.ssl.fastly.net" \
|
4
|
+
PREFAB_LOG_CLIENT_BOOTSTRAP_LOG_LEVEL=debug \
|
5
|
+
PREFAB_CLOUD_HTTP=true \
|
6
|
+
PREFAB_API_KEY="1|local_development_api_key" \
|
7
|
+
PREFAB_GRPC_URL="localhost:50051" \
|
8
|
+
ruby -Ilib test/harness_server.rb
|
@@ -1,6 +1,32 @@
|
|
1
|
-
sample:
|
1
|
+
sample: default sample value
|
2
2
|
sample_int: 123
|
3
3
|
sample_double: 12.12
|
4
4
|
sample_bool: true
|
5
|
+
false_value: false
|
6
|
+
zero_value: 0
|
5
7
|
sample_to_override: Foo
|
6
8
|
prefab.log_level: debug
|
9
|
+
unit_tests:
|
10
|
+
sample: test sample value
|
11
|
+
enabled_flag: true
|
12
|
+
disabled_flag: false
|
13
|
+
flag_with_a_value:
|
14
|
+
feature_flag: true
|
15
|
+
value: "all-features"
|
16
|
+
in_lookup_key:
|
17
|
+
feature_flag: true
|
18
|
+
value: true
|
19
|
+
criteria:
|
20
|
+
operator: LOOKUP_KEY_IN
|
21
|
+
values:
|
22
|
+
- abc123
|
23
|
+
- xyz987
|
24
|
+
just_my_domain:
|
25
|
+
feature_flag: true
|
26
|
+
value: new-version
|
27
|
+
criteria:
|
28
|
+
operator: PROP_IS_ONE_OF
|
29
|
+
property: domain
|
30
|
+
values: ["prefab.cloud", "example.com"]
|
31
|
+
ignored_env:
|
32
|
+
sample: ignored value
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'prefab-cloud-ruby'
|
3
|
+
require 'rack'
|
4
|
+
require 'base64'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
handler = Rack::Handler::Thin
|
8
|
+
|
9
|
+
#
|
10
|
+
# This is a very lightweight server that allows the compliance harness to excercise the prefab client
|
11
|
+
#
|
12
|
+
class RackApp
|
13
|
+
def call(env)
|
14
|
+
props = CGI::parse(env["QUERY_STRING"])
|
15
|
+
props = JSON.parse(Base64.decode64(props["props"][0]))
|
16
|
+
|
17
|
+
key = props["key"]
|
18
|
+
namespace = props["namespace"]
|
19
|
+
api_key = props["api_key"]
|
20
|
+
user_key = props["user_key"]
|
21
|
+
is_feature_flag = !props["feature_flag"].nil?
|
22
|
+
attributes = props["attributes"]
|
23
|
+
puts props
|
24
|
+
|
25
|
+
options = Prefab::Options.new(
|
26
|
+
api_key: api_key,
|
27
|
+
namespace: namespace,
|
28
|
+
initialization_timeout_sec: 1,
|
29
|
+
# We want to `return` rather than raise so we'll use the initial payload if we can't connect to the SSE server
|
30
|
+
on_init_failure: Prefab::Options::ON_INITIALIZATION_FAILURE::RETURN,
|
31
|
+
# Want to return `nil` rather than raise so we can verify empty values
|
32
|
+
on_no_default: Prefab::Options::ON_NO_DEFAULT::RETURN_NIL
|
33
|
+
)
|
34
|
+
|
35
|
+
client = Prefab::Client.new(options)
|
36
|
+
|
37
|
+
puts "Key #{key}"
|
38
|
+
puts "User #{user_key}"
|
39
|
+
puts "api_key #{api_key}"
|
40
|
+
puts "Namespace #{namespace}"
|
41
|
+
puts "Props! #{props}"
|
42
|
+
puts "is_feature_flag! #{is_feature_flag}"
|
43
|
+
|
44
|
+
puts client.config_client.to_s
|
45
|
+
|
46
|
+
if is_feature_flag
|
47
|
+
puts "EVALFF #{key} #{user_key}"
|
48
|
+
rtn = client.feature_flag_client.get(key, user_key, attributes).to_s
|
49
|
+
else
|
50
|
+
rtn = client.config_client.get(key).to_s
|
51
|
+
end
|
52
|
+
|
53
|
+
puts "return #{rtn}"
|
54
|
+
|
55
|
+
[200, { "Content-Type" => "text/plain" }, rtn]
|
56
|
+
|
57
|
+
rescue Exception => e
|
58
|
+
puts "ERROR #{e.message}"
|
59
|
+
puts e.backtrace
|
60
|
+
[500, { "Content-Type" => "text/plain" }, e.message]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
handler.run RackApp.new
|