prefab-cloud-ruby 0.23.7 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_logger.rb CHANGED
@@ -192,7 +192,7 @@ class TestLogger < Minitest::Test
192
192
  Prefab::Criterion.new(
193
193
  operator: Prefab::Criterion::CriterionOperator::PROP_IS_ONE_OF,
194
194
  value_to_match: string_list(['hotmail.com', 'gmail.com']),
195
- property_name: 'email_suffix'
195
+ property_name: 'user.email_suffix'
196
196
  )
197
197
  ],
198
198
  value: Prefab::ConfigValue.new(log_level: WRONG_ENV_VALUE)
@@ -209,7 +209,7 @@ class TestLogger < Minitest::Test
209
209
  Prefab::Criterion.new(
210
210
  operator: Prefab::Criterion::CriterionOperator::PROP_IS_ONE_OF,
211
211
  value_to_match: string_list(['hotmail.com', 'gmail.com']),
212
- property_name: 'email_suffix'
212
+ property_name: 'user.email_suffix'
213
213
  )
214
214
  ],
215
215
  value: Prefab::ConfigValue.new(log_level: DESIRED_VALUE)
@@ -228,7 +228,7 @@ class TestLogger < Minitest::Test
228
228
  inject_project_env_id(prefab, PROJECT_ENV_ID)
229
229
 
230
230
  # without any context, the level should be the default for the env (info)
231
- prefab.with_log_context(nil, {}) do
231
+ prefab.with_context({}) do
232
232
  prefab.log.debug 'Test debug'
233
233
  refute_logged io, 'Test debug'
234
234
 
@@ -242,7 +242,7 @@ class TestLogger < Minitest::Test
242
242
  reset_io(io)
243
243
 
244
244
  # with the wrong context, the level should be the default for the env (info)
245
- prefab.with_log_context('user:1234', email_suffix: 'yahoo.com') do
245
+ prefab.with_context(user: { email_suffix: 'yahoo.com' }) do
246
246
  prefab.log.debug 'Test debug'
247
247
  refute_logged io, 'Test debug'
248
248
 
@@ -256,7 +256,7 @@ class TestLogger < Minitest::Test
256
256
  reset_io(io)
257
257
 
258
258
  # with the correct context, the level should be the desired value (debug)
259
- prefab.with_log_context('user:1234', email_suffix: 'hotmail.com') do
259
+ prefab.with_context(user: { email_suffix: 'hotmail.com' }) do
260
260
  prefab.log.debug 'Test debug'
261
261
  assert_logged io, 'DEBUG', "#{prefix}.test.test_logger.test_logging_with_criteria_on_top_level_key", 'Test debug'
262
262
 
@@ -302,7 +302,7 @@ class TestLogger < Minitest::Test
302
302
  Prefab::Criterion.new(
303
303
  operator: Prefab::Criterion::CriterionOperator::PROP_IS_ONE_OF,
304
304
  value_to_match: string_list(['hotmail.com', 'gmail.com']),
305
- property_name: 'email_suffix'
305
+ property_name: 'user.email_suffix'
306
306
  )
307
307
  ],
308
308
  value: Prefab::ConfigValue.new(log_level: DESIRED_VALUE)
@@ -311,9 +311,9 @@ class TestLogger < Minitest::Test
311
311
  Prefab::ConditionalValue.new(
312
312
  criteria: [
313
313
  Prefab::Criterion.new(
314
- operator: Prefab::Criterion::CriterionOperator::LOOKUP_KEY_IN,
314
+ operator: Prefab::Criterion::CriterionOperator::PROP_IS_ONE_OF,
315
315
  value_to_match: string_list(%w[user:4567]),
316
- property_name: Prefab::CriteriaEvaluator::LOOKUP_KEY
316
+ property_name: 'user.tracking_id'
317
317
  )
318
318
  ],
319
319
  value: Prefab::ConfigValue.new(log_level: DESIRED_VALUE)
@@ -333,7 +333,7 @@ class TestLogger < Minitest::Test
333
333
  inject_project_env_id(prefab, PROJECT_ENV_ID)
334
334
 
335
335
  # without any context, the level should be the default for the env (info)
336
- prefab.with_log_context(nil, {}) do
336
+ prefab.with_context({}) do
337
337
  prefab.log.debug 'Test debug'
338
338
  refute_logged io, 'Test debug'
339
339
 
@@ -347,7 +347,7 @@ class TestLogger < Minitest::Test
347
347
  reset_io(io)
348
348
 
349
349
  # with the wrong context, the level should be the default for the env (info)
350
- prefab.with_log_context('user:1234', email_suffix: 'yahoo.com') do
350
+ prefab.with_context(user: { email_suffix: 'yahoo.com' }) do
351
351
  prefab.log.debug 'Test debug'
352
352
  refute_logged io, 'Test debug'
353
353
 
@@ -361,7 +361,7 @@ class TestLogger < Minitest::Test
361
361
  reset_io(io)
362
362
 
363
363
  # with the correct context, the level should be the desired value (debug)
364
- prefab.with_log_context('user:1234', email_suffix: 'hotmail.com') do
364
+ prefab.with_context(user: { email_suffix: 'hotmail.com' }) do
365
365
  prefab.log.debug 'Test debug'
366
366
  assert_logged io, 'DEBUG', "#{prefix}.test.test_logger.test_logging_with_criteria_on_key_path", 'Test debug'
367
367
 
@@ -375,7 +375,7 @@ class TestLogger < Minitest::Test
375
375
  reset_io(io)
376
376
 
377
377
  # with the correct lookup key
378
- prefab.with_log_context('user:4567', email_suffix: 'example.com') do
378
+ prefab.with_context(user: { tracking_id: 'user:4567' }) do
379
379
  prefab.log.debug 'Test debug'
380
380
  assert_logged io, 'DEBUG', "#{prefix}.test.test_logger.test_logging_with_criteria_on_key_path", 'Test debug'
381
381
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prefab-cloud-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.7
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dwyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-21 00:00:00.000000000 Z
11
+ date: 2023-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -197,6 +197,7 @@ files:
197
197
  - lib/prefab/config_loader.rb
198
198
  - lib/prefab/config_resolver.rb
199
199
  - lib/prefab/config_value_unwrapper.rb
200
+ - lib/prefab/context.rb
200
201
  - lib/prefab/criteria_evaluator.rb
201
202
  - lib/prefab/error.rb
202
203
  - lib/prefab/errors/initialization_timeout_error.rb
@@ -213,11 +214,11 @@ files:
213
214
  - lib/prefab/noop_cache.rb
214
215
  - lib/prefab/noop_stats.rb
215
216
  - lib/prefab/options.rb
217
+ - lib/prefab/resolved_config_presenter.rb
216
218
  - lib/prefab/sse_logger.rb
217
219
  - lib/prefab/weighted_value_resolver.rb
218
220
  - lib/prefab/yaml_config_parser.rb
219
221
  - lib/prefab_pb.rb
220
- - lib/prefab_services_pb.rb
221
222
  - prefab-cloud-ruby.gemspec
222
223
  - test/.prefab.default.config.yaml
223
224
  - test/.prefab.unit_tests.config.yaml
@@ -228,6 +229,7 @@ files:
228
229
  - test/test_config_loader.rb
229
230
  - test/test_config_resolver.rb
230
231
  - test/test_config_value_unwrapper.rb
232
+ - test/test_context.rb
231
233
  - test/test_criteria_evaluator.rb
232
234
  - test/test_exponential_backoff.rb
233
235
  - test/test_feature_flag_client.rb
@@ -1,80 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # Source: prefab.proto for package 'prefab'
3
-
4
- require 'grpc'
5
- require 'prefab_pb'
6
-
7
- module Prefab
8
- module RateLimitService
9
- class Service
10
-
11
- include ::GRPC::GenericService
12
-
13
- self.marshal_class_method = :encode
14
- self.unmarshal_class_method = :decode
15
- self.service_name = 'prefab.RateLimitService'
16
-
17
- rpc :LimitCheck, ::Prefab::LimitRequest, ::Prefab::LimitResponse
18
- end
19
-
20
- Stub = Service.rpc_stub_class
21
- end
22
- module ConfigService
23
- class Service
24
-
25
- include ::GRPC::GenericService
26
-
27
- self.marshal_class_method = :encode
28
- self.unmarshal_class_method = :decode
29
- self.service_name = 'prefab.ConfigService'
30
-
31
- rpc :GetConfig, ::Prefab::ConfigServicePointer, stream(::Prefab::Configs)
32
- rpc :GetAllConfig, ::Prefab::ConfigServicePointer, ::Prefab::Configs
33
- rpc :Upsert, ::Prefab::Config, ::Prefab::CreationResponse
34
- end
35
-
36
- Stub = Service.rpc_stub_class
37
- end
38
- module IdService
39
- class Service
40
-
41
- include ::GRPC::GenericService
42
-
43
- self.marshal_class_method = :encode
44
- self.unmarshal_class_method = :decode
45
- self.service_name = 'prefab.IdService'
46
-
47
- rpc :GetBlock, ::Prefab::IdBlockRequest, ::Prefab::IdBlock
48
- end
49
-
50
- Stub = Service.rpc_stub_class
51
- end
52
- module ClientService
53
- class Service
54
-
55
- include ::GRPC::GenericService
56
-
57
- self.marshal_class_method = :encode
58
- self.unmarshal_class_method = :decode
59
- self.service_name = 'prefab.ClientService'
60
-
61
- rpc :GetAll, ::Prefab::Identity, ::Prefab::ConfigEvaluations
62
- end
63
-
64
- Stub = Service.rpc_stub_class
65
- end
66
- module LoggerReportingService
67
- class Service
68
-
69
- include ::GRPC::GenericService
70
-
71
- self.marshal_class_method = :encode
72
- self.unmarshal_class_method = :decode
73
- self.service_name = 'prefab.LoggerReportingService'
74
-
75
- rpc :Send, ::Prefab::Loggers, ::Prefab::LoggerReportResponse
76
- end
77
-
78
- Stub = Service.rpc_stub_class
79
- end
80
- end