prefab-cloud-ruby 0.23.0 → 0.23.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cd914702e6efb141278bbf12bf120342c0de3d788e8e6399a3baefd8f11a102
4
- data.tar.gz: d7ba7ad4210bbf2f89005479e970f33b6486a67fbef125502c86455830381797
3
+ metadata.gz: 6e93ba84e2ea630c852605f1bf814b5388dcaa8fd83025402d2dbc9afa8340cc
4
+ data.tar.gz: 8a751a537cbdf658015630b26e5cdc4d284bcc018c702712e60148e68890f0c0
5
5
  SHA512:
6
- metadata.gz: a797285f8e5ecffc90b5861f87af50c5aae93f6dc3ba1803b79232823ee4ff2fa4fdf4017c04712aa89fa5f607496eb99376dbc6595bcfad69e2df2ae0aa0324
7
- data.tar.gz: 965bc69143e55822b5a53d691eb50ee5a883b50e85dfe3ecf868ab58b947efc717b752d287d636636846418539c2ce602451b12b4a29f596a41a41be2839ef7e
6
+ metadata.gz: f460a0d55982126a5fb1591d380936355ab175e93963dddf18aba9a5b6c2f599d36784afc6afe85aef01870d3069d3aab1cb52967a1a508f2d76aa6287b3599f
7
+ data.tar.gz: 1ce748c099c1414b98ca4476ec392e46068984196f4d6b261b6ee3acf696b86ae237ff63121a9a5050b500bd53fc957aadea7cec9d586cde75a3b8c4e543967c
data/Gemfile.lock CHANGED
@@ -30,11 +30,11 @@ GEM
30
30
  faraday (>= 0.8, < 2)
31
31
  hashie (~> 3.5, >= 3.5.2)
32
32
  oauth2 (~> 1.0)
33
- google-protobuf (3.21.9)
34
- googleapis-common-protos-types (1.3.0)
33
+ google-protobuf (3.22.2)
34
+ googleapis-common-protos-types (1.5.0)
35
35
  google-protobuf (~> 3.14)
36
- grpc (1.43.1)
37
- google-protobuf (~> 3.18)
36
+ grpc (1.53.0)
37
+ google-protobuf (~> 3.21)
38
38
  googleapis-common-protos-types (~> 1.0)
39
39
  grpc-tools (1.43.1)
40
40
  hashie (3.6.0)
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # prefab-cloud-ruby
2
- Ruby Client for Prefab FeatureFlags, Config as a Service: https://www.prefab.cloud
2
+
3
+ Ruby Client for Prefab Feature Flags, Dynamic log levels, and Config as a Service: https://www.prefab.cloud
3
4
 
4
5
  ```ruby
5
6
  client = Prefab::Client.new
@@ -20,25 +21,36 @@ See full documentation https://docs.prefab.cloud/docs/ruby-sdk/ruby
20
21
 
21
22
  ## Supports
22
23
 
23
- * [FeatureFlags](https://www.prefab.cloud/documentation/feature_flags) as a Service
24
- * Millions of individual limits sharing the same policies
25
- * WebUI for tweaking limits & feature flags
26
- * Infinite retention for [deduplication workflows](https://www.prefab.cloud/documentation/once_and_only_once)
24
+ * Feature Flags
25
+ * Dynamic log levels
26
+ * Live Config
27
+ * WebUI for tweaking config, log levels, and feature flags
27
28
 
28
29
  ## Important note about Forking and realtime updates
29
- Many ruby web servers fork. GRPC does not like to be forked. You should manually start gRPC streaming in the on_worker_boot or after_fork hook of your server. See some details on GRPC and forking: https://github.com/grpc/grpc/issues/7951#issuecomment-335998583
30
30
 
31
- ```ruby
31
+ Many ruby web servers fork. GRPC does not like to be forked. See some details on GRPC and forking: https://github.com/grpc/grpc/issues/7951#issuecomment-335998583
32
32
 
33
+ If you're using Puma or Unicorn, you can do the following.
34
+
35
+ ```ruby
33
36
  #config/initializers/prefab.rb
34
37
  $prefab = Prefab::Client.new
35
- Rails.logger = $prefab.log
38
+ $prefab.set_rails_loggers
36
39
  ```
37
40
 
38
41
  ```ruby
39
42
  #puma.rb
40
43
  on_worker_boot do
41
- $prefab.config_client.start_streaming
44
+ $prefab = Prefab::Client.new
45
+ $prefab.set_rails_loggers
46
+ end
47
+ ```
48
+
49
+ ```ruby
50
+ # unicorn.rb
51
+ after_fork do |server, worker|
52
+ $prefab = Prefab::Client.new(options)
53
+ $prefab.set_rails_loggers
42
54
  end
43
55
  ```
44
56
 
@@ -76,5 +88,4 @@ REMOTE_BRANCH=main LOCAL_BRANCH=main bundle exec rake release
76
88
 
77
89
  ## Copyright
78
90
 
79
- Copyright (c) 2023 Jeff Dwyer. See LICENSE.txt for
80
- further details.
91
+ Copyright (c) 2023 Jeff Dwyer. See LICENSE.txt for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.23.0
1
+ 0.23.2
data/lib/prefab/client.rb CHANGED
@@ -90,7 +90,7 @@ module Prefab
90
90
  ActionController::Base.logger = log
91
91
  ActiveJob::Base.logger = log
92
92
  ActiveRecord::Base.logger = log
93
- ActiveStorage.logger = log
93
+ ActiveStorage.logger = log if defined?(ActiveStorage)
94
94
  end
95
95
 
96
96
  def log_internal(level, msg, path = nil)
@@ -34,6 +34,8 @@ module Prefab
34
34
  end
35
35
  end
36
36
  str
37
+ rescue StandardError => e
38
+ "Error printing resolved config: #{e.message}"
37
39
  end
38
40
 
39
41
  def raw(key)
@@ -88,7 +88,7 @@ module Prefab
88
88
  end
89
89
 
90
90
  def log_internal(message)
91
- @client.log.log_internal message, 'log_path_collector', nil, ::Logger::INFO
91
+ @client.log.log_internal message, 'log_path_collector', nil, ::Logger::DEBUG
92
92
  end
93
93
 
94
94
  def now
@@ -71,7 +71,7 @@ module Prefab
71
71
  @namespace = namespace
72
72
  @log_formatter = log_formatter
73
73
  @log_prefix = log_prefix
74
- @prefab_api_url = prefab_api_url
74
+ @prefab_api_url = remove_trailing_slash(prefab_api_url)
75
75
  @prefab_grpc_url = prefab_grpc_url
76
76
  @on_no_default = on_no_default
77
77
  @initialization_timeout_sec = initialization_timeout_sec
@@ -103,5 +103,11 @@ module Prefab
103
103
  def url_for_api_cdn
104
104
  ENV['PREFAB_CDN_URL'] || "#{@prefab_api_url.gsub(/\./, '-')}.global.ssl.fastly.net"
105
105
  end
106
+
107
+ private
108
+
109
+ def remove_trailing_slash(url)
110
+ url.end_with?('/') ? url[0..-2] : url
111
+ end
106
112
  end
107
113
  end
@@ -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.23.0 ruby lib
5
+ # stub: prefab-cloud-ruby 0.23.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "prefab-cloud-ruby".freeze
9
- s.version = "0.23.0"
9
+ s.version = "0.23.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]
13
13
  s.authors = ["Jeff Dwyer".freeze]
14
- s.date = "2023-03-28"
14
+ s.date = "2023-04-04"
15
15
  s.description = "RateLimits & Config as a service".freeze
16
16
  s.email = "jdwyer@prefab.cloud".freeze
17
17
  s.extra_rdoc_files = [
data/test/test_options.rb CHANGED
@@ -5,6 +5,18 @@ require 'test_helper'
5
5
  class TestOptions < Minitest::Test
6
6
  API_KEY = 'abcdefg'
7
7
 
8
+ def test_prefab_api_url
9
+ assert_equal 'https://api.prefab.cloud', Prefab::Options.new.prefab_api_url
10
+
11
+ with_env 'PREFAB_API_URL', 'https://api.prefab.cloud' do
12
+ assert_equal 'https://api.prefab.cloud', Prefab::Options.new.prefab_api_url
13
+ end
14
+
15
+ with_env 'PREFAB_API_URL', 'https://api.prefab.cloud/' do
16
+ assert_equal 'https://api.prefab.cloud', Prefab::Options.new.prefab_api_url
17
+ end
18
+ end
19
+
8
20
  def test_works_with_named_arguments
9
21
  assert_equal API_KEY, Prefab::Options.new(api_key: API_KEY).api_key
10
22
  end
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.0
4
+ version: 0.23.2
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-03-28 00:00:00.000000000 Z
11
+ date: 2023-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby