unleash 6.1.2 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6bd9703fdba109b3d5a0e22153ab9e04b25afb855641b955d02cee2d3a1cf9e
4
- data.tar.gz: 4df84602002a6968fe115ae490b463da9cfbbf7e2524f2bbaff1dc838cb9adf2
3
+ metadata.gz: 4370c29490f14c2ece25f21614db57de48b748cea8215da748d7635bd9d27bbf
4
+ data.tar.gz: eb2cdff78e994647a70fca33497d144f0e4366d75612670077c1689d6d37dcac
5
5
  SHA512:
6
- metadata.gz: a9b8dcd7e176a3e7356a8b516f664ca24d7ac99e5b2d93f38e80ce2835417a7a5ab9e8b9c5e61433a5500889db23dcdbaa8b96f468bdebd55aa4235f045b3256
7
- data.tar.gz: f37909173947cf1e59840efc0449dd19e7a83b7b03aed69ccd875c2c9df7e926d72f845cdfebb6dd263d66265a3c90e882a4097d7d408e10ff86336246535e22
6
+ metadata.gz: 63a24dbca52e439f57c24a4c1f6894f172386ee898704e4570877c59b3a2b542e98eff9463b75a01fb54f5aa37ecab43e98b12119dbe03cf87be4e0e6792cae6
7
+ data.tar.gz: caa9b7b541d60b3ab99f5cbf270adac69211fe4424e80202ad12c4882f49295829a3aeb267cd7400fee5dbe393fcd355cc8db7fb9ebf419ee04a31dc1c0840ba
@@ -30,11 +30,15 @@ jobs:
30
30
  - windows
31
31
  ruby-version:
32
32
  - jruby-9.4
33
+ - 3.4
33
34
  - 3.3
34
35
  - 3.2
35
36
  - 3.1
36
37
  - '3.0'
37
38
  - 2.7
39
+ exclude:
40
+ - os: windows
41
+ ruby-version: jruby-9.4
38
42
 
39
43
  needs:
40
44
  - lint
@@ -66,15 +70,6 @@ jobs:
66
70
  github-token: ${{ secrets.GITHUB_TOKEN }}
67
71
  flag-name: run-${{ matrix.test_number }}
68
72
  parallel: true
69
- - name: Notify Slack of pipeline completion
70
- uses: 8398a7/action-slack@v3
71
- if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
72
- with:
73
- status: ${{ job.status }}
74
- text: Built on ${{ matrix.os }} - Ruby ${{ matrix.ruby-version }}
75
- fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
76
- env:
77
- SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
78
73
 
79
74
  finish:
80
75
  needs: test
data/CHANGELOG.md CHANGED
@@ -13,6 +13,14 @@ Note: These changes are not considered notable:
13
13
 
14
14
  ## [Unreleased]
15
15
 
16
+ ## [6.2.0] - 2024-02-28
17
+ ### Added
18
+ - unleash-interval header (#236)
19
+ - connectionId in metrics and registration payload (#236)
20
+ - default interval changed from 10s to 15s (#236)
21
+ - update Yggdrasil engine (#228)
22
+ - delta API configuration option (#228)
23
+
16
24
  ## [6.1.2] - 2024-01-30
17
25
  ### Fixed
18
26
  - drop x- header prefix (#229)
data/README.md CHANGED
@@ -13,6 +13,7 @@ Ruby client for the [Unleash](https://github.com/Unleash/unleash) feature manage
13
13
 
14
14
  ## Supported Ruby interpreters
15
15
 
16
+ - MRI 3.4
16
17
  - MRI 3.3
17
18
  - MRI 3.2
18
19
  - MRI 3.1
@@ -25,7 +26,7 @@ Ruby client for the [Unleash](https://github.com/Unleash/unleash) feature manage
25
26
  Add this line to your application's Gemfile:
26
27
 
27
28
  ```ruby
28
- gem 'unleash', '~> 6.1.0'
29
+ gem 'unleash', '~> 6.1.2'
29
30
  ```
30
31
 
31
32
  And then execute:
@@ -116,6 +116,7 @@ module Unleash
116
116
  {
117
117
  'appName': Unleash.configuration.app_name,
118
118
  'instanceId': Unleash.configuration.instance_id,
119
+ 'connectionId': Unleash.configuration.connection_id,
119
120
  'sdkVersion': "unleash-client-ruby:" + Unleash::VERSION,
120
121
  'strategies': Unleash.strategies.known_strategies,
121
122
  'started': Time.now.iso8601(Unleash::TIME_RESOLUTION),
@@ -21,7 +21,9 @@ module Unleash
21
21
  :logger,
22
22
  :log_level,
23
23
  :bootstrap_config,
24
- :strategies
24
+ :strategies,
25
+ :use_delta_api
26
+ attr_reader :connection_id
25
27
 
26
28
  def initialize(opts = {})
27
29
  validate_custom_http_headers!(opts[:custom_http_headers]) if opts.has_key?(:custom_http_headers)
@@ -50,18 +52,27 @@ module Unleash
50
52
  end
51
53
 
52
54
  def http_headers
53
- {
55
+ headers = {
54
56
  'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
55
57
  'UNLEASH-INSTANCEID' => self.instance_id,
56
58
  'UNLEASH-APPNAME' => self.app_name,
57
- 'UNLEASH-CONNECTION-ID' => @connection_id,
58
- 'UNLEASH-SDK' => "unleash-client-ruby:#{Unleash::VERSION}",
59
- 'Unleash-Client-Spec' => CLIENT_SPECIFICATION_VERSION
59
+ 'Unleash-Client-Spec' => CLIENT_SPECIFICATION_VERSION,
60
+ 'UNLEASH-SDK' => "unleash-client-ruby:#{Unleash::VERSION}"
60
61
  }.merge!(generate_custom_http_headers)
62
+ headers['UNLEASH-CONNECTION-ID'] = @connection_id
63
+ headers
61
64
  end
62
65
 
63
66
  def fetch_toggles_uri
64
- uri = URI("#{self.url_stripped_of_slash}/client/features")
67
+ uri = nil
68
+ ## Personal feeling but Rubocop's suggestion here is too dense to be properly readable
69
+ # rubocop:disable Style/ConditionalAssignment
70
+ if self.use_delta_api
71
+ uri = URI("#{self.url_stripped_of_slash}/client/delta")
72
+ else
73
+ uri = URI("#{self.url_stripped_of_slash}/client/features")
74
+ end
75
+ # rubocop:enable Style/ConditionalAssignment
65
76
  uri.query = "project=#{self.project_name}" unless self.project_name.nil?
66
77
  uri
67
78
  end
@@ -92,7 +103,7 @@ module Unleash
92
103
  self.project_name = nil
93
104
  self.disable_client = false
94
105
  self.disable_metrics = false
95
- self.refresh_interval = 10
106
+ self.refresh_interval = 15
96
107
  self.metrics_interval = 60
97
108
  self.timeout = 30
98
109
  self.retry_limit = Float::INFINITY
@@ -100,6 +111,7 @@ module Unleash
100
111
  self.log_level = Logger::WARN
101
112
  self.bootstrap_config = nil
102
113
  self.strategies = Unleash::Strategies.new
114
+ self.use_delta_api = false
103
115
 
104
116
  self.custom_http_headers = {}
105
117
  @connection_id = SecureRandom.uuid
@@ -23,6 +23,7 @@ module Unleash
23
23
  'specVersion': Unleash::CLIENT_SPECIFICATION_VERSION,
24
24
  'appName': Unleash.configuration.app_name,
25
25
  'instanceId': Unleash.configuration.instance_id,
26
+ 'connectionId': Unleash.configuration.connection_id,
26
27
  'bucket': metrics || {}
27
28
  }
28
29
  end
@@ -37,7 +38,9 @@ module Unleash
37
38
  return
38
39
  end
39
40
 
40
- response = Unleash::Util::Http.post(Unleash.configuration.client_metrics_uri, report.to_json)
41
+ headers = (Unleash.configuration.http_headers || {}).dup
42
+ headers.merge!({ 'UNLEASH-INTERVAL' => Unleash.configuration.metrics_interval.to_s })
43
+ response = Unleash::Util::Http.post(Unleash.configuration.client_metrics_uri, report.to_json, headers)
41
44
 
42
45
  if ['200', '202'].include? response.code
43
46
  Unleash.logger.debug "Report sent to unleash server successfully. Server responded with http code #{response.code}"
@@ -1,3 +1,3 @@
1
1
  module Unleash
2
- CLIENT_SPECIFICATION_VERSION = "5.1.9".freeze
2
+ CLIENT_SPECIFICATION_VERSION = "5.2.0".freeze
3
3
  end
@@ -37,13 +37,16 @@ module Unleash
37
37
  Unleash.logger.debug "fetch()"
38
38
  return if Unleash.configuration.disable_client
39
39
 
40
- response = Unleash::Util::Http.get(Unleash.configuration.fetch_toggles_uri, etag)
40
+ headers = (Unleash.configuration.http_headers || {}).dup
41
+ headers.merge!({ 'UNLEASH-INTERVAL' => Unleash.configuration.refresh_interval.to_s })
42
+ response = Unleash::Util::Http.get(Unleash.configuration.fetch_toggles_uri, etag, headers)
41
43
 
42
44
  if response.code == '304'
43
45
  Unleash.logger.debug "No changes according to the unleash server, nothing to do."
44
46
  return
45
47
  elsif response.code != '200'
46
- raise IOError, "Unleash server returned a non 200/304 HTTP result."
48
+ raise IOError, "Unleash server returned unexpected HTTP response code #{response.code}."\
49
+ " Only handle response codes 200 (indicates changes) or 304 (no changes)."
47
50
  end
48
51
 
49
52
  self.etag = response['ETag']
@@ -81,6 +84,8 @@ module Unleash
81
84
 
82
85
  # notify all threads waiting for this resource to no longer wait
83
86
  self.toggle_resource.broadcast
87
+ rescue StandardError => e
88
+ Unleash.logger.error "Failed to hydrate state: #{e.backtrace}"
84
89
  end
85
90
 
86
91
  def read!
@@ -12,10 +12,10 @@ module Unleash
12
12
  http.request(request)
13
13
  end
14
14
 
15
- def self.post(uri, body)
15
+ def self.post(uri, body, headers_override = nil)
16
16
  http = http_connection(uri)
17
17
 
18
- request = Net::HTTP::Post.new(uri.request_uri, http_headers)
18
+ request = Net::HTTP::Post.new(uri.request_uri, http_headers(nil, headers_override))
19
19
  request.body = body
20
20
 
21
21
  http.request(request)
@@ -1,3 +1,3 @@
1
1
  module Unleash
2
- VERSION = "6.1.2".freeze
2
+ VERSION = "6.2.0".freeze
3
3
  end
@@ -23,7 +23,10 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
  spec.required_ruby_version = ">= 2.7"
25
25
 
26
- spec.add_dependency "yggdrasil-engine", "~> 1.0.1"
26
+ spec.add_dependency "yggdrasil-engine", "~> 1.0.3"
27
+
28
+ spec.add_dependency "base64", "~> 0.2.0"
29
+ spec.add_dependency "logger", "~> 1.6.5"
27
30
 
28
31
  spec.add_development_dependency "bundler", "~> 2.1"
29
32
  spec.add_development_dependency "rake", "~> 12.3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unleash
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.2
4
+ version: 6.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renato Arruda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-04 00:00:00.000000000 Z
11
+ date: 2025-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yggdrasil-engine
@@ -16,14 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.1
19
+ version: 1.0.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.1
26
+ version: 1.0.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: base64
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: logger
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.6.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.5
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: bundler
29
57
  requirement: !ruby/object:Gem::Requirement