prefab-cloud-ruby 0.20.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.envrc.sample +3 -0
  3. data/.github/workflows/ruby.yml +5 -1
  4. data/.gitmodules +3 -0
  5. data/Gemfile +14 -12
  6. data/Gemfile.lock +24 -14
  7. data/README.md +12 -10
  8. data/Rakefile +13 -14
  9. data/VERSION +1 -1
  10. data/lib/prefab/auth_interceptor.rb +2 -1
  11. data/lib/prefab/cancellable_interceptor.rb +8 -7
  12. data/lib/prefab/client.rb +52 -27
  13. data/lib/prefab/config_client.rb +59 -70
  14. data/lib/prefab/config_loader.rb +7 -114
  15. data/lib/prefab/config_resolver.rb +27 -57
  16. data/lib/prefab/config_value_unwrapper.rb +23 -0
  17. data/lib/prefab/criteria_evaluator.rb +96 -0
  18. data/lib/prefab/errors/invalid_api_key_error.rb +1 -1
  19. data/lib/prefab/feature_flag_client.rb +13 -145
  20. data/lib/prefab/internal_logger.rb +7 -6
  21. data/lib/prefab/local_config_parser.rb +110 -0
  22. data/lib/prefab/log_path_collector.rb +98 -0
  23. data/lib/prefab/logger_client.rb +46 -44
  24. data/lib/prefab/murmer3.rb +3 -4
  25. data/lib/prefab/noop_cache.rb +5 -7
  26. data/lib/prefab/noop_stats.rb +2 -3
  27. data/lib/prefab/options.rb +32 -11
  28. data/lib/prefab/ratelimit_client.rb +11 -13
  29. data/lib/prefab/sse_logger.rb +3 -2
  30. data/lib/prefab/weighted_value_resolver.rb +42 -0
  31. data/lib/prefab/yaml_config_parser.rb +32 -0
  32. data/lib/prefab-cloud-ruby.rb +7 -2
  33. data/lib/prefab_pb.rb +70 -43
  34. data/lib/prefab_services_pb.rb +14 -1
  35. data/prefab-cloud-ruby.gemspec +33 -19
  36. data/test/.prefab.unit_tests.config.yaml +3 -2
  37. data/test/integration_test.rb +98 -0
  38. data/test/integration_test_helpers.rb +37 -0
  39. data/test/test_client.rb +56 -31
  40. data/test/test_config_client.rb +21 -20
  41. data/test/test_config_loader.rb +48 -37
  42. data/test/test_config_resolver.rb +312 -135
  43. data/test/test_config_value_unwrapper.rb +83 -0
  44. data/test/test_criteria_evaluator.rb +533 -0
  45. data/test/test_feature_flag_client.rb +35 -347
  46. data/test/test_helper.rb +18 -14
  47. data/test/test_integration.rb +33 -0
  48. data/test/test_local_config_parser.rb +78 -0
  49. data/test/test_log_path_collector.rb +56 -0
  50. data/test/test_logger.rb +52 -51
  51. data/test/test_options.rb +32 -0
  52. data/test/test_weighted_value_resolver.rb +65 -0
  53. metadata +30 -16
  54. data/lib/prefab/config_helper.rb +0 -31
  55. data/run_test_harness_server.sh +0 -8
  56. data/test/harness_server.rb +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1d4612e27cae5a4e66065a16d8d70cb0b1c7120770eac8c7e09ce3ca0e48e82
4
- data.tar.gz: 1d1f50b6b4605729b93d62194b17ed9a1fca739f435ec2a4e682482a293bffe6
3
+ metadata.gz: f5df09f0991b0d46c29ce33bc010116733960a5004ede7dd5a0df868b15e4a29
4
+ data.tar.gz: ded97aa4f8e2dc37e7581ee5d29c7bcb3eff88e7aa8f72fedb7bd9710050bfec
5
5
  SHA512:
6
- metadata.gz: ed5a04b2a16a79b0963d9af2dd71955141fdd06e7d73a4897adf74245435cf33239f78b08bbde797b7420b7e988fbb76e5e4333e6da5350f1037502949c469e7
7
- data.tar.gz: 1b6f556bb94a31c272d5cd3c585860cacb4698be61830379c1a1a7e2d2fdcb461c02777e0c6fdb6a2cc939dcb070a27237506bd3c21d69ccd723ec50dccfbf2a
6
+ metadata.gz: 5e44b86fabd88830aed86910f4ff9175df14a06dc30b19821c741c691a9637bcff69870de0d816c2348a650dc9eb5b3a3c54a4452f71039aaab2f042086c3536
7
+ data.tar.gz: d81cf8af71e9aa189e7ba8b7078af6472df4dc6e3b08a33771163363424986d8b194c0ed88fa961217758ee9e5d21ca5604810f96db53a80366d72df606cb6d7
data/.envrc.sample ADDED
@@ -0,0 +1,3 @@
1
+ export AWS_ACCESS_KEY_ID=
2
+ export AWS_SECRET_ACCESS_KEY=
3
+ export PREFAB_INTEGRATION_TEST_API_KEY=
@@ -22,10 +22,12 @@ jobs:
22
22
  runs-on: ubuntu-latest
23
23
  strategy:
24
24
  matrix:
25
- ruby-version: ['2.6', '2.7', '3.0']
25
+ ruby-version: ['2.6', '2.7', '3.0', '3.1']
26
26
 
27
27
  steps:
28
28
  - uses: actions/checkout@v3
29
+ with:
30
+ submodules: recursive
29
31
  - name: Set up Ruby
30
32
  # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
33
  # change this to (see https://github.com/ruby/setup-ruby#versioning):
@@ -37,3 +39,5 @@ jobs:
37
39
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
38
40
  - name: Run tests
39
41
  run: bundle exec rake
42
+ env:
43
+ PREFAB_INTEGRATION_TEST_API_KEY: ${{ secrets.PREFAB_INTEGRATION_TEST_API_KEY }}
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "test/prefab-cloud-integration-test-data"]
2
+ path = test/prefab-cloud-integration-test-data
3
+ url = git@github.com:prefab-cloud/prefab-cloud-integration-test-data
data/Gemfile CHANGED
@@ -1,23 +1,25 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'concurrent-ruby', '~> 1.0', '>= 1.0.5'
4
4
  gem 'faraday'
5
+ gem 'googleapis-common-protos-types', platforms: :ruby
6
+ gem 'google-protobuf', platforms: :ruby
7
+ gem 'grpc', platforms: :ruby
5
8
  gem 'ld-eventsource'
6
- gem 'grpc', :platforms => :ruby
7
- gem 'google-protobuf', :platforms => :ruby
8
- gem 'googleapis-common-protos-types', :platforms => :ruby
9
+ gem 'uuid'
9
10
 
10
11
  group :development do
11
12
  gem 'benchmark-ips'
12
- gem 'grpc-tools', :platforms => :ruby
13
- gem "rdoc"
14
- gem "bundler"
15
- gem "juwelier", "~> 2.4.9"
16
- gem "simplecov", ">= 0"
17
- gem 'thin'
13
+ gem 'bundler'
14
+ gem 'grpc-tools', platforms: :ruby
15
+ gem 'juwelier', '~> 2.4.9'
16
+ gem 'rdoc'
17
+ gem 'simplecov', '>= 0'
18
18
  end
19
19
 
20
20
  group :test do
21
- gem "minitest"
22
- gem "minitest-focus"
21
+ gem 'minitest'
22
+ gem 'minitest-focus'
23
+ gem 'minitest-reporters'
24
+ gem 'timecop'
23
25
  end
data/Gemfile.lock CHANGED
@@ -3,16 +3,15 @@ GEM
3
3
  specs:
4
4
  addressable (2.8.0)
5
5
  public_suffix (>= 2.0.2, < 5.0)
6
+ ansi (1.5.0)
6
7
  benchmark-ips (2.10.0)
7
8
  builder (3.2.4)
8
9
  concurrent-ruby (1.1.10)
9
- daemons (1.4.1)
10
10
  descendants_tracker (0.0.4)
11
11
  thread_safe (~> 0.3, >= 0.3.1)
12
12
  docile (1.3.5)
13
13
  domain_name (0.5.20190701)
14
14
  unf (>= 0.0.5, < 1.0.0)
15
- eventmachine (1.2.7)
16
15
  faraday (1.3.0)
17
16
  faraday-net_http (~> 1.0)
18
17
  multipart-post (>= 1.2, < 3)
@@ -22,7 +21,8 @@ GEM
22
21
  ffi-compiler (1.0.1)
23
22
  ffi (>= 1.0.0)
24
23
  rake
25
- git (1.11.0)
24
+ git (1.13.0)
25
+ addressable (~> 2.8)
26
26
  rchardet (~> 1.8)
27
27
  github_api (0.19.0)
28
28
  addressable (~> 2.4)
@@ -68,43 +68,51 @@ GEM
68
68
  llhttp-ffi (0.3.1)
69
69
  ffi-compiler (~> 1.0)
70
70
  rake (~> 13.0)
71
+ macaddr (1.7.2)
72
+ systemu (~> 2.6.5)
71
73
  mini_portile2 (2.8.0)
72
74
  minitest (5.16.2)
73
75
  minitest-focus (1.3.1)
74
76
  minitest (>= 4, < 6)
77
+ minitest-reporters (1.5.0)
78
+ ansi
79
+ builder
80
+ minitest (>= 5.0)
81
+ ruby-progressbar
75
82
  multi_json (1.15.0)
76
83
  multi_xml (0.6.0)
77
84
  multipart-post (2.1.1)
78
- nokogiri (1.13.9)
85
+ nokogiri (1.13.10)
79
86
  mini_portile2 (~> 2.8.0)
80
87
  racc (~> 1.4)
81
- oauth2 (1.4.7)
82
- faraday (>= 0.8, < 2.0)
88
+ oauth2 (1.4.11)
89
+ faraday (>= 0.17.3, < 3.0)
83
90
  jwt (>= 1.0, < 3.0)
84
91
  multi_json (~> 1.3)
85
92
  multi_xml (~> 0.5)
86
- rack (>= 1.2, < 3)
93
+ rack (>= 1.2, < 4)
87
94
  psych (3.3.1)
88
95
  public_suffix (4.0.6)
89
- racc (1.6.0)
90
- rack (2.2.4)
96
+ racc (1.6.1)
97
+ rack (3.0.4.1)
91
98
  rake (13.0.6)
92
99
  rchardet (1.8.0)
93
100
  rdoc (6.3.3)
101
+ ruby-progressbar (1.11.0)
94
102
  ruby2_keywords (0.0.4)
95
103
  semver2 (3.4.2)
96
104
  simplecov (0.18.5)
97
105
  docile (~> 1.1)
98
106
  simplecov-html (~> 0.11)
99
107
  simplecov-html (0.12.3)
100
- thin (1.8.1)
101
- daemons (~> 1.0, >= 1.0.9)
102
- eventmachine (~> 1.0, >= 1.0.4)
103
- rack (>= 1, < 3)
108
+ systemu (2.6.5)
104
109
  thread_safe (0.3.6)
110
+ timecop (0.9.4)
105
111
  unf (0.1.4)
106
112
  unf_ext
107
113
  unf_ext (0.0.8)
114
+ uuid (2.3.9)
115
+ macaddr (~> 1.0)
108
116
 
109
117
  PLATFORMS
110
118
  ruby
@@ -122,9 +130,11 @@ DEPENDENCIES
122
130
  ld-eventsource
123
131
  minitest
124
132
  minitest-focus
133
+ minitest-reporters
125
134
  rdoc
126
135
  simplecov
127
- thin
136
+ timecop
137
+ uuid
128
138
 
129
139
  BUNDLED WITH
130
140
  2.3.5
data/README.md CHANGED
@@ -3,18 +3,20 @@ Ruby Client for Prefab FeatureFlags, Config as a Service: https://www.prefab.clo
3
3
 
4
4
  ```ruby
5
5
  client = Prefab::Client.new
6
- @feature_flags = client.feature_flag_client
7
6
 
8
- # Create a flag that is on for 10% of traffic, the entire beta group and user:1
9
- @feature_flags.upsert(Prefab::FeatureFlag.new(feature: "MyFeature", pct: 0.1, whitelisted: ["betas", "user:1"]))
7
+ lookup_key = "user-123"
8
+ identity_attributes = {
9
+ team_id: 432,
10
+ user_id: 123,
11
+ subscription_level: 'pro',
12
+ email: "alice@example.com"
13
+ }
10
14
 
11
- # Use Flags By Themselves
12
- puts @feature_flags.feature_is_on? "MyFeature" # returns yes 10 pct of the time
15
+ result = client.enabled? "my-first-feature-flag", lookup_key, identity_attributes
13
16
 
14
- # A single user should get the same result each time
15
- puts @feature_flags.feature_is_on? "MyFeature", "user:1123"
17
+ puts "my-first-feature-flag is: #{result} for #{lookup_key}"
16
18
  ```
17
- See full documentation https://www.prefab.cloud/documentation/installation
19
+ See full documentation https://docs.prefab.cloud/docs/ruby-sdk/ruby
18
20
 
19
21
  ## Supports
20
22
 
@@ -41,7 +43,7 @@ end
41
43
  ```
42
44
 
43
45
  ## Logging & Debugging
44
- In classpath or ~/.prefab.overrides.config.yaml set
46
+ In classpath or ~/.prefab.default.config.yaml set
45
47
 
46
48
  ```
47
49
  log-level:
@@ -74,5 +76,5 @@ REMOTE_BRANCH=main LOCAL_BRANCH=main bundle exec rake release
74
76
 
75
77
  ## Copyright
76
78
 
77
- Copyright (c) 2022 Jeff Dwyer. See LICENSE.txt for
79
+ Copyright (c) 2023 Jeff Dwyer. See LICENSE.txt for
78
80
  further details.
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'rubygems'
@@ -6,21 +5,21 @@ require 'bundler'
6
5
  begin
7
6
  Bundler.setup(:default, :development)
8
7
  rescue Bundler::BundlerError => e
9
- $stderr.puts e.message
10
- $stderr.puts "Run `bundle install` to install missing gems"
8
+ warn e.message
9
+ warn 'Run `bundle install` to install missing gems'
11
10
  exit e.status_code
12
11
  end
13
12
  require 'rake'
14
13
  require 'juwelier'
15
14
  Juwelier::Tasks.new do |gem|
16
15
  # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
- gem.name = "prefab-cloud-ruby"
18
- gem.homepage = "http://github.com/prefab-cloud/prefab-cloud-ruby"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Prefab Ruby Infrastructure}
21
- gem.description = %Q{RateLimits & Config as a service}
22
- gem.email = "jdwyer@prefab.cloud"
23
- gem.authors = ["Jeff Dwyer"]
16
+ gem.name = 'prefab-cloud-ruby'
17
+ gem.homepage = 'http://github.com/prefab-cloud/prefab-cloud-ruby'
18
+ gem.license = 'MIT'
19
+ gem.summary = %(Prefab Ruby Infrastructure)
20
+ gem.description = %(RateLimits & Config as a service)
21
+ gem.email = 'jdwyer@prefab.cloud'
22
+ gem.authors = ['Jeff Dwyer']
24
23
 
25
24
  # dependencies defined in Gemfile
26
25
  end
@@ -32,17 +31,17 @@ Rake::TestTask.new(:test) do |test|
32
31
  test.verbose = true
33
32
  end
34
33
 
35
- desc "Code coverage detail"
34
+ desc 'Code coverage detail'
36
35
  task :simplecov do
37
- ENV['COVERAGE'] = "true"
36
+ ENV['COVERAGE'] = 'true'
38
37
  Rake::Task['test'].execute
39
38
  end
40
39
 
41
- task :default => :test
40
+ task default: :test
42
41
 
43
42
  require 'rdoc/task'
44
43
  Rake::RDocTask.new do |rdoc|
45
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ''
46
45
 
47
46
  rdoc.rdoc_dir = 'rdoc'
48
47
  rdoc.title = "prefab-cloud-ruby #{version}"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.20.0
1
+ 0.22.0
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Prefab
3
4
  class AuthInterceptor < GRPC::ClientInterceptor
4
- VERSION = File.exist?('VERSION') ? File.read('VERSION').chomp : ""
5
+ VERSION = File.exist?('VERSION') ? File.read('VERSION').chomp : ''
5
6
  CLIENT = "prefab-cloud-ruby.#{VERSION}".freeze
6
7
 
7
8
  def initialize(api_key)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Prefab
3
4
  class CancellableInterceptor < GRPC::ClientInterceptor
4
5
  WAIT_SEC = 3
@@ -8,20 +9,20 @@ module Prefab
8
9
  end
9
10
 
10
11
  def cancel
11
- @call.instance_variable_get("@wrapped").instance_variable_get("@call").cancel
12
+ @call.instance_variable_get('@wrapped').instance_variable_get('@call').cancel
12
13
  i = 0
13
- while (i < WAIT_SEC) do
14
- if @call.instance_variable_get("@wrapped").cancelled?
15
- @base_client.log_internal Logger::DEBUG, "Cancelled streaming."
14
+ while i < WAIT_SEC
15
+ if @call.instance_variable_get('@wrapped').cancelled?
16
+ @base_client.log_internal ::Logger::DEBUG, 'Cancelled streaming.'
16
17
  return
17
18
  else
18
- @base_client.log_internal Logger::DEBUG, "Unable to cancel streaming. Trying again"
19
- @call.instance_variable_get("@wrapped").instance_variable_get("@call").cancel
19
+ @base_client.log_internal ::Logger::DEBUG, 'Unable to cancel streaming. Trying again'
20
+ @call.instance_variable_get('@wrapped').instance_variable_get('@call').cancel
20
21
  i += 1
21
22
  sleep(1)
22
23
  end
23
24
  end
24
- @base_client.log_internal Logger::INFO, "Unable to cancel streaming."
25
+ @base_client.log_internal ::Logger::INFO, 'Unable to cancel streaming.'
25
26
  end
26
27
 
27
28
  def request_response(request:, call:, method:, metadata:, &block)
data/lib/prefab/client.rb CHANGED
@@ -1,28 +1,41 @@
1
1
  # frozen_string_literal: true
2
+
3
+ require 'uuid'
4
+
2
5
  module Prefab
3
6
  class Client
4
7
  MAX_SLEEP_SEC = 10
5
8
  BASE_SLEEP_SEC = 0.5
6
9
  NO_DEFAULT_PROVIDED = :no_default_provided
7
10
 
8
- attr_reader :shared_cache, :stats, :namespace, :interceptor, :api_key, :prefab_api_url, :options
11
+ attr_reader :shared_cache
12
+ attr_reader :stats
13
+ attr_reader :namespace
14
+ attr_reader :interceptor
15
+ attr_reader :api_key
16
+ attr_reader :prefab_api_url
17
+ attr_reader :options
18
+ attr_reader :instance_hash
9
19
 
10
20
  def initialize(options = Prefab::Options.new)
11
- @options = options
21
+ @options = options.is_a?(Prefab::Options) ? options : Prefab::Options.new(options)
12
22
  @shared_cache = @options.shared_cache
13
23
  @stats = @options.stats
14
24
  @namespace = @options.namespace
15
25
  @stubs = {}
26
+ @instance_hash = UUID.new.generate
16
27
 
17
28
  if @options.local_only?
18
- log_internal Logger::INFO, "Prefab Running in Local Mode"
29
+ log_internal ::Logger::INFO, 'Prefab Running in Local Mode'
19
30
  else
20
31
  @api_key = @options.api_key
21
- raise Prefab::Errors::InvalidApiKeyError.new(@api_key) if @api_key.nil? || @api_key.empty? || api_key.count("-") < 1
32
+ raise Prefab::Errors::InvalidApiKeyError, @api_key if @api_key.nil? || @api_key.empty? || api_key.count('-') < 1
33
+
22
34
  @interceptor = Prefab::AuthInterceptor.new(@api_key)
23
35
  @prefab_api_url = @options.prefab_api_url
24
36
  @prefab_grpc_url = @options.prefab_grpc_url
25
- log_internal Logger::INFO, "Prefab Connecting to: #{@prefab_api_url} and #{@prefab_grpc_url} Secure: #{http_secure?}"
37
+ log_internal ::Logger::INFO,
38
+ "Prefab Connecting to: #{@prefab_api_url} and #{@prefab_grpc_url} Secure: #{http_secure?}"
26
39
  at_exit do
27
40
  channel.destroy
28
41
  end
@@ -46,9 +59,17 @@ module Prefab
46
59
  @feature_flag_client ||= Prefab::FeatureFlagClient.new(self)
47
60
  end
48
61
 
62
+ def log_path_collector
63
+ return nil if @options.collect_max_paths <= 0
64
+
65
+ @log_path_collector ||= LogPathCollector.new(client: self, max_paths: @options.collect_max_paths,
66
+ sync_interval: @options.collect_sync_interval)
67
+ end
68
+
49
69
  def log
50
70
  @logger_client ||= Prefab::LoggerClient.new(@options.logdev, formatter: @options.log_formatter,
51
- prefix: @options.log_prefix)
71
+ prefix: @options.log_prefix,
72
+ log_path_collector: log_path_collector)
52
73
  end
53
74
 
54
75
  def log_internal(level, msg, path = nil)
@@ -56,6 +77,9 @@ module Prefab
56
77
  end
57
78
 
58
79
  def request(service, method, req_options: {}, params: {})
80
+ # Future-proofing since we previously bumped into a conflict with a service with a `send` method
81
+ raise ArgumentError, 'Cannot call public_send on an grpc service in Ruby' if method.to_s == 'public_send'
82
+
59
83
  opts = { timeout: 10 }.merge(req_options)
60
84
 
61
85
  attempts = 0
@@ -63,18 +87,17 @@ module Prefab
63
87
 
64
88
  begin
65
89
  attempts += 1
66
- return stub_for(service, opts[:timeout]).send(method, *params)
67
- rescue => exception
68
90
 
69
- log_internal Logger::WARN, exception
91
+ stub_for(service, opts[:timeout]).public_send(method, *params)
92
+ rescue StandardError => e
93
+ log_internal ::Logger::WARN, e
70
94
 
71
- if Time.now - start_time > opts[:timeout]
72
- raise exception
73
- end
74
- sleep_seconds = [BASE_SLEEP_SEC * (2 ** (attempts - 1)), MAX_SLEEP_SEC].min
75
- sleep_seconds = sleep_seconds * (0.5 * (1 + rand()))
95
+ raise e if Time.now - start_time > opts[:timeout]
96
+
97
+ sleep_seconds = [BASE_SLEEP_SEC * (2**(attempts - 1)), MAX_SLEEP_SEC].min
98
+ sleep_seconds *= (0.5 * (1 + rand))
76
99
  sleep_seconds = [BASE_SLEEP_SEC, sleep_seconds].max
77
- log_internal Logger::INFO, "Sleep #{sleep_seconds} and Reset #{service} #{method}"
100
+ log_internal ::Logger::INFO, "Sleep #{sleep_seconds} and Reset #{service} #{method}"
78
101
  sleep sleep_seconds
79
102
  reset!
80
103
  retry
@@ -86,24 +109,28 @@ module Prefab
86
109
  @_channel = nil
87
110
  end
88
111
 
89
- def enabled?(feature_name, lookup_key=nil, attributes={})
112
+ def enabled?(feature_name, lookup_key = nil, attributes = {})
90
113
  feature_flag_client.feature_is_on_for?(feature_name, lookup_key, attributes: attributes)
91
114
  end
92
115
 
93
- def get(key, default_or_lookup_key=NO_DEFAULT_PROVIDED, attributes={}, ff_default=NO_DEFAULT_PROVIDED)
94
- result = config_client.get(key, default_or_lookup_key)
95
-
96
- if result.is_a?(Prefab::FeatureFlag)
97
- feature_flag_client.get(key, default_or_lookup_key, attributes, default: ff_default)
116
+ def get(key, default_or_lookup_key = NO_DEFAULT_PROVIDED, properties = {}, ff_default = nil)
117
+ if is_ff?(key)
118
+ feature_flag_client.get(key, default_or_lookup_key, properties, default: ff_default)
98
119
  else
99
- result
120
+ config_client.get(key, default_or_lookup_key, properties)
100
121
  end
101
122
  end
102
123
 
103
124
  private
104
125
 
126
+ def is_ff?(key)
127
+ raw = config_client.send(:raw, key)
128
+
129
+ raw && raw.allowable_values.any?
130
+ end
131
+
105
132
  def http_secure?
106
- ENV["PREFAB_CLOUD_HTTP"] != "true"
133
+ ENV['PREFAB_CLOUD_HTTP'] != 'true'
107
134
  end
108
135
 
109
136
  def stub_for(service, timeout)
@@ -119,7 +146,7 @@ module Prefab
119
146
  end
120
147
 
121
148
  def ssl_certs
122
- ssl_certs = ""
149
+ ssl_certs = ''
123
150
  Dir["#{OpenSSL::X509::DEFAULT_CERT_DIR}/*.pem"].each do |cert|
124
151
  ssl_certs += File.open(cert).read
125
152
  end
@@ -127,11 +154,9 @@ module Prefab
127
154
  ssl_certs += File.open(OpenSSL::X509::DEFAULT_CERT_FILE).read
128
155
  end
129
156
  ssl_certs
130
- rescue => e
157
+ rescue StandardError => e
131
158
  log.warn("Issue loading SSL certs #{e.message}")
132
159
  ssl_certs
133
160
  end
134
-
135
161
  end
136
162
  end
137
-