prefab-cloud-ruby 0.23.1 → 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: 55f7405129237177e62c5dfe267782a09825ef548daa1dc4991ab21a66769455
4
- data.tar.gz: ec4e47e424a6898f31bcba403293de19d8a70d67a951c3d6a830e5cdbb71156e
3
+ metadata.gz: 6e93ba84e2ea630c852605f1bf814b5388dcaa8fd83025402d2dbc9afa8340cc
4
+ data.tar.gz: 8a751a537cbdf658015630b26e5cdc4d284bcc018c702712e60148e68890f0c0
5
5
  SHA512:
6
- metadata.gz: 0e78923408d4bf39a2a73c7e9d90c88274b1da106ff148094c2bcba694195d93eab81d373fe36e404740e0266f06b35d928bc21caa10e85c374fbf3667d055af
7
- data.tar.gz: db4052d845d6dbda926579da65af9bececa24c96676b44f0d7af01bfed85e527d4768d22b095867f6ec6ec6d30d8e3975fd6edebf4af4d9ea47d1550a5215fb9
6
+ metadata.gz: f460a0d55982126a5fb1591d380936355ab175e93963dddf18aba9a5b6c2f599d36784afc6afe85aef01870d3069d3aab1cb52967a1a508f2d76aa6287b3599f
7
+ data.tar.gz: 1ce748c099c1414b98ca4476ec392e46068984196f4d6b261b6ee3acf696b86ae237ff63121a9a5050b500bd53fc957aadea7cec9d586cde75a3b8c4e543967c
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.1
1
+ 0.23.2
@@ -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.1 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.1"
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-30"
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.1
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-30 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