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.
- checksums.yaml +4 -4
- data/.envrc.sample +3 -0
- data/.github/workflows/ruby.yml +5 -1
- data/.gitmodules +3 -0
- data/Gemfile +14 -12
- data/Gemfile.lock +24 -14
- data/README.md +12 -10
- data/Rakefile +13 -14
- data/VERSION +1 -1
- data/lib/prefab/auth_interceptor.rb +2 -1
- data/lib/prefab/cancellable_interceptor.rb +8 -7
- data/lib/prefab/client.rb +52 -27
- data/lib/prefab/config_client.rb +59 -70
- data/lib/prefab/config_loader.rb +7 -114
- data/lib/prefab/config_resolver.rb +27 -57
- data/lib/prefab/config_value_unwrapper.rb +23 -0
- data/lib/prefab/criteria_evaluator.rb +96 -0
- data/lib/prefab/errors/invalid_api_key_error.rb +1 -1
- data/lib/prefab/feature_flag_client.rb +13 -145
- data/lib/prefab/internal_logger.rb +7 -6
- data/lib/prefab/local_config_parser.rb +110 -0
- data/lib/prefab/log_path_collector.rb +98 -0
- data/lib/prefab/logger_client.rb +46 -44
- data/lib/prefab/murmer3.rb +3 -4
- data/lib/prefab/noop_cache.rb +5 -7
- data/lib/prefab/noop_stats.rb +2 -3
- data/lib/prefab/options.rb +32 -11
- data/lib/prefab/ratelimit_client.rb +11 -13
- data/lib/prefab/sse_logger.rb +3 -2
- data/lib/prefab/weighted_value_resolver.rb +42 -0
- data/lib/prefab/yaml_config_parser.rb +32 -0
- data/lib/prefab-cloud-ruby.rb +7 -2
- data/lib/prefab_pb.rb +70 -43
- data/lib/prefab_services_pb.rb +14 -1
- data/prefab-cloud-ruby.gemspec +33 -19
- data/test/.prefab.unit_tests.config.yaml +3 -2
- data/test/integration_test.rb +98 -0
- data/test/integration_test_helpers.rb +37 -0
- data/test/test_client.rb +56 -31
- data/test/test_config_client.rb +21 -20
- data/test/test_config_loader.rb +48 -37
- data/test/test_config_resolver.rb +312 -135
- data/test/test_config_value_unwrapper.rb +83 -0
- data/test/test_criteria_evaluator.rb +533 -0
- data/test/test_feature_flag_client.rb +35 -347
- data/test/test_helper.rb +18 -14
- data/test/test_integration.rb +33 -0
- data/test/test_local_config_parser.rb +78 -0
- data/test/test_log_path_collector.rb +56 -0
- data/test/test_logger.rb +52 -51
- data/test/test_options.rb +32 -0
- data/test/test_weighted_value_resolver.rb +65 -0
- metadata +30 -16
- data/lib/prefab/config_helper.rb +0 -31
- data/run_test_harness_server.sh +0 -8
- data/test/harness_server.rb +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5df09f0991b0d46c29ce33bc010116733960a5004ede7dd5a0df868b15e4a29
|
4
|
+
data.tar.gz: ded97aa4f8e2dc37e7581ee5d29c7bcb3eff88e7aa8f72fedb7bd9710050bfec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e44b86fabd88830aed86910f4ff9175df14a06dc30b19821c741c691a9637bcff69870de0d816c2348a650dc9eb5b3a3c54a4452f71039aaab2f042086c3536
|
7
|
+
data.tar.gz: d81cf8af71e9aa189e7ba8b7078af6472df4dc6e3b08a33771163363424986d8b194c0ed88fa961217758ee9e5d21ca5604810f96db53a80366d72df606cb6d7
|
data/.envrc.sample
ADDED
data/.github/workflows/ruby.yml
CHANGED
@@ -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
data/Gemfile
CHANGED
@@ -1,23 +1,25 @@
|
|
1
|
-
source
|
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 '
|
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 '
|
13
|
-
gem
|
14
|
-
gem
|
15
|
-
gem
|
16
|
-
gem
|
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
|
22
|
-
gem
|
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.
|
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.
|
85
|
+
nokogiri (1.13.10)
|
79
86
|
mini_portile2 (~> 2.8.0)
|
80
87
|
racc (~> 1.4)
|
81
|
-
oauth2 (1.4.
|
82
|
-
faraday (>= 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, <
|
93
|
+
rack (>= 1.2, < 4)
|
87
94
|
psych (3.3.1)
|
88
95
|
public_suffix (4.0.6)
|
89
|
-
racc (1.6.
|
90
|
-
rack (
|
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
|
-
|
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
|
-
|
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
|
-
|
9
|
-
|
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
|
-
|
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
|
-
|
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://
|
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.
|
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)
|
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
|
-
|
10
|
-
|
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 =
|
18
|
-
gem.homepage =
|
19
|
-
gem.license =
|
20
|
-
gem.summary = %
|
21
|
-
gem.description = %
|
22
|
-
gem.email =
|
23
|
-
gem.authors = [
|
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
|
34
|
+
desc 'Code coverage detail'
|
36
35
|
task :simplecov do
|
37
|
-
ENV['COVERAGE'] =
|
36
|
+
ENV['COVERAGE'] = 'true'
|
38
37
|
Rake::Task['test'].execute
|
39
38
|
end
|
40
39
|
|
41
|
-
task :
|
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.
|
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(
|
12
|
+
@call.instance_variable_get('@wrapped').instance_variable_get('@call').cancel
|
12
13
|
i = 0
|
13
|
-
while
|
14
|
-
if @call.instance_variable_get(
|
15
|
-
@base_client.log_internal Logger::DEBUG,
|
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,
|
19
|
-
@call.instance_variable_get(
|
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,
|
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
|
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,
|
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
|
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,
|
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
|
-
|
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
|
-
|
73
|
-
|
74
|
-
sleep_seconds
|
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,
|
94
|
-
|
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
|
-
|
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[
|
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
|
-
|