patient_http-sidekiq 1.0.2 → 1.1.1

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: f244dd52326602169e67b8471527b939c3e451fd11dcbcfe424305d5ad0929dd
4
- data.tar.gz: 28b502c3aca097c48e364195e338e475d67f4f584209797054e2cc8ed75dda90
3
+ metadata.gz: f16c7b27f88a7f84cb0b34cb6ae28a931b9be60dcfa22c8107efeff1cf9bb82c
4
+ data.tar.gz: f6c20d30b05984bd72d21f4faea53f4eb2f5e08637894f09c286abc1df437640
5
5
  SHA512:
6
- metadata.gz: 12bb283a157d40689ffadfb5fdb58b74260374017409f99185a650f989d54da2ff858bbccac294fd6fe7095c0150cc024a0e15649280d0d1aaf5da04d2211b12
7
- data.tar.gz: a27fbd9f52d110b05bb4177dd675642dde873c3a519078ea8c95f295c96f8be499e8fff119e79a8c0f446d1c6d608e537c374dceda993d98bcdf2081ef9e0a00
6
+ metadata.gz: 9d79dc80c1493605c18763b89533aeed861c3ab6e49d6ae29558d7650297752bccff9efaec56bf425366f2db79c48125351db0d1dd5b7310d353bf5af50ef9bd
7
+ data.tar.gz: 84c003b789d2809bfccd9e6ef11ddf80d56712ed963bb3e5bc5769cf7b6b7bdbfc4720e260b034cb0b99d340991f30a526bdd774cba1adccf811cdf2fd8c07f3
data/CHANGELOG.md CHANGED
@@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## 1.1.1
8
+
9
+ ### Fixed
10
+
11
+ - The Sidekiq Web UI extension now registers correctly on Sidekiq 7.3. It previously raised `NoMethodError: undefined method 'register_extension' for class Sidekiq::Web` because that method only exists in Sidekiq 8.
12
+ - The Web UI dashboard page now renders on Sidekiq versions before 8.1. Those versions resolve view files as `*.erb` instead of `*.html.erb`, so the template is now rendered from a string.
13
+ - Requiring the Web UI on Sidekiq versions before 7.3 now raises a `LoadError` with a clear message instead of an obscure error.
14
+
15
+ ### Added
16
+
17
+ - `require "patient_http/sidekiq/web"` can now be used to load the Web UI extension, matching the `require "sidekiq/web"` convention. The previous `patient_http/sidekiq/web_ui` path still works.
18
+
19
+ ## 1.1.0
20
+
21
+ ### Changed
22
+
23
+ - `PatientHttp::Sidekiq.configure` now sets the built configuration as the `PatientHttp.default_configuration` so that secrets registered at the module level with `PatientHttp.register_secret` are applied to the configuration the processor runs with, regardless of boot order. This requires patient_http 1.3.0 or newer.
24
+
7
25
  ## 1.0.2
8
26
 
9
27
  ### Fixed
data/README.md CHANGED
@@ -485,12 +485,11 @@ See the [Configuration](lib/patient_http/sidekiq/configuration.rb) class for all
485
485
 
486
486
  ### Web UI
487
487
 
488
- If you're using Sidekiq's Web UI, you can add a tab with the async HTTP processor statistics. The extension auto-registers when `Sidekiq::Web` is defined:
488
+ If you're using Sidekiq's Web UI, you can add a tab with the async HTTP processor statistics. The Web UI tab requires Sidekiq 7.3 or later.
489
489
 
490
490
  ```ruby
491
491
  # config/routes.rb (Rails)
492
- require "sidekiq/web"
493
- require "patient_http-sidekiq"
492
+ require "patient_http/sidekiq/web"
494
493
 
495
494
  mount Sidekiq::Web => "/sidekiq"
496
495
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.1.1
@@ -2,7 +2,7 @@
2
2
 
3
3
  module PatientHttp
4
4
  module Sidekiq
5
- # Configuration for the Sidekiq Async HTTP gem.
5
+ # Configuration for the Sidekiq integration.
6
6
  #
7
7
  # Wraps PatientHttp::Configuration with Sidekiq-aware defaults and adds
8
8
  # Sidekiq-specific options like worker queue/retry settings.
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file exists so that the require path for the web UI can match the
4
+ # file path in sidekiq itself: `require "patient_http/sidekiq/web"`
5
+
6
+ require_relative "web_ui"
@@ -1,5 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sidekiq/version"
4
+
5
+ # Sidekiq 7.3 introduced the web extension API used here (register with
6
+ # keyword arguments); older versions cannot mount the tab or assets. Check
7
+ # before loading sidekiq/web, which can itself fail to load on old versions.
8
+ if Gem::Version.new(::Sidekiq::VERSION) < Gem::Version.new("7.3")
9
+ raise LoadError.new("patient_http/sidekiq/web requires sidekiq >= 7.3 (you have #{::Sidekiq::VERSION})")
10
+ end
11
+
3
12
  require "sidekiq/web"
4
13
 
5
14
  module PatientHttp
@@ -12,6 +21,13 @@ module PatientHttp
12
21
  VIEWS = File.join(ROOT, "views")
13
22
 
14
23
  class << self
24
+ # Sidekiq resolves symbol view names to different file names depending
25
+ # on the version (*.erb before 8.1, *.html.erb from 8.1 on), so the
26
+ # template is rendered from a string instead.
27
+ def template
28
+ @template ||= File.read(File.join(VIEWS, "patient_http.html.erb"))
29
+ end
30
+
15
31
  # This method is called by Sidekiq::Web when registering the extension
16
32
  def registered(app)
17
33
  # GET route for the main PatientHttp dashboard page
@@ -31,7 +47,7 @@ module PatientHttp
31
47
  current_inflight = processes.values.sum { |data| data[:inflight] }
32
48
  utilization = (max_capacity > 0) ? (current_inflight.to_f / max_capacity * 100).round(1) : 0
33
49
 
34
- erb(:patient_http, views: PatientHttp::Sidekiq::WebUI::VIEWS, locals: {
50
+ erb(PatientHttp::Sidekiq::WebUI.template, locals: {
35
51
  totals: totals,
36
52
  total_requests: total_requests,
37
53
  avg_duration: avg_duration,
@@ -52,18 +68,26 @@ module PatientHttp
52
68
  end
53
69
  end
54
70
 
55
- # Auto-register the web UI extension if Sidekiq::Web is available
56
- # This is called after require "sidekiq/web" in the application
57
- if defined?(::Sidekiq::Web)
71
+ register_options = {
72
+ name: "patient-http",
73
+ tab: "patient_http_tab",
74
+ index: "patient-http",
75
+ root_dir: PatientHttp::Sidekiq::WebUI::ROOT,
76
+ asset_paths: ["css", "js"]
77
+ }
78
+
79
+ if ::Sidekiq::Web.respond_to?(:configure)
58
80
  ::Sidekiq::Web.configure do |config|
59
- config.register_extension(
60
- PatientHttp::Sidekiq::WebUI,
61
- name: "patient-http",
62
- tab: "patient_http_tab",
63
- index: "patient-http",
64
- root_dir: PatientHttp::Sidekiq::WebUI::ROOT,
65
- asset_paths: ["css", "js"]
66
- )
81
+ if config.respond_to?(:register_extension)
82
+ # Sidekiq 8.x yields a Sidekiq::Web::Config object
83
+ config.register_extension(PatientHttp::Sidekiq::WebUI, **register_options)
84
+ else
85
+ # Sidekiq 7.3.5+ yields the Sidekiq::Web class, which only has register
86
+ config.register(PatientHttp::Sidekiq::WebUI, **register_options)
87
+ end
67
88
  end
89
+ else
90
+ # Sidekiq 7.3.0 - 7.3.4 has no Sidekiq::Web.configure
91
+ ::Sidekiq::Web.register(PatientHttp::Sidekiq::WebUI, **register_options)
68
92
  end
69
93
  end
@@ -92,7 +92,11 @@ module PatientHttp
92
92
  class << self
93
93
  attr_writer :configuration
94
94
 
95
- # Configure the gem with a block
95
+ # Configure the gem with a block. The built configuration is also set as the
96
+ # `PatientHttp.default_configuration` so that secrets registered at the module
97
+ # level with `PatientHttp.register_secret` are applied to the configuration the
98
+ # processor runs with, regardless of boot order.
99
+ #
96
100
  # @yield [Configuration] the configuration object
97
101
  # @return [Configuration]
98
102
  def configure
@@ -101,6 +105,7 @@ module PatientHttp
101
105
  @configuration = configuration
102
106
  @external_storage = nil
103
107
  register_handler
108
+ PatientHttp.default_configuration = configuration
104
109
  configuration
105
110
  end
106
111
 
@@ -40,7 +40,5 @@ Gem::Specification.new do |spec|
40
40
  spec.required_ruby_version = ">= 3.2"
41
41
 
42
42
  spec.add_dependency "sidekiq", ">= 7.0"
43
- spec.add_dependency "patient_http"
44
-
45
- spec.add_development_dependency "bundler"
43
+ spec.add_dependency "patient_http", ">= 1.3.0"
46
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patient_http-sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Durand
@@ -29,28 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: 1.3.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '0'
40
- - !ruby/object:Gem::Dependency
41
- name: bundler
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- type: :development
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
39
+ version: 1.3.0
54
40
  description: This gem provides a mechanism to offload long-running HTTP requests from
55
41
  Sidekiq workers to a dedicated async I/O processor running in the same process,
56
42
  freeing the worker thread immediately while the HTTP request is in flight.
@@ -78,6 +64,7 @@ files:
78
64
  - lib/patient_http/sidekiq/task_handler.rb
79
65
  - lib/patient_http/sidekiq/task_monitor.rb
80
66
  - lib/patient_http/sidekiq/task_monitor_thread.rb
67
+ - lib/patient_http/sidekiq/web.rb
81
68
  - lib/patient_http/sidekiq/web_ui.rb
82
69
  - lib/patient_http/sidekiq/web_ui/assets/patient-http/css/patient_http.css
83
70
  - lib/patient_http/sidekiq/web_ui/locales/ar.yml
@@ -133,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
120
  - !ruby/object:Gem::Version
134
121
  version: '0'
135
122
  requirements: []
136
- rubygems_version: 4.0.3
123
+ rubygems_version: 3.6.9
137
124
  specification_version: 4
138
125
  summary: Offload long-running HTTP requests from Sidekiq workers to a dedicated async
139
126
  I/O processor