patient_http-sidekiq 1.1.0 → 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: b97f976999ea59ac067153a7698579accb7e7a9941171adbb31e1270ff044fc8
4
- data.tar.gz: bf45c48c1afaae62826c66f8a2a8f5cd82379b40edc0c9d34faad1c856cfbcd2
3
+ metadata.gz: f16c7b27f88a7f84cb0b34cb6ae28a931b9be60dcfa22c8107efeff1cf9bb82c
4
+ data.tar.gz: f6c20d30b05984bd72d21f4faea53f4eb2f5e08637894f09c286abc1df437640
5
5
  SHA512:
6
- metadata.gz: bff1df1ca4265615ec56aedce59ef87a08f70344f31324e432e231d114c7b04139424a29cf510d8aac6cc0dad2643149cf1f4b17c194066e3fe13deea4a8989b
7
- data.tar.gz: 2fb165723aecdd602a638f81a3a2804ff3951e1b3db74c4dc1afbc5a6e32420adc9728fbe06d503bd424616fd5c665faf8cb93b74bbcde2b2193681d0c6f3651
6
+ metadata.gz: 9d79dc80c1493605c18763b89533aeed861c3ab6e49d6ae29558d7650297752bccff9efaec56bf425366f2db79c48125351db0d1dd5b7310d353bf5af50ef9bd
7
+ data.tar.gz: 84c003b789d2809bfccd9e6ef11ddf80d56712ed963bb3e5bc5769cf7b6b7bdbfc4720e260b034cb0b99d340991f30a526bdd774cba1adccf811cdf2fd8c07f3
data/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ 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
+
7
19
  ## 1.1.0
8
20
 
9
21
  ### Changed
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.1.0
1
+ 1.1.1
@@ -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
@@ -41,6 +41,4 @@ Gem::Specification.new do |spec|
41
41
 
42
42
  spec.add_dependency "sidekiq", ">= 7.0"
43
43
  spec.add_dependency "patient_http", ">= 1.3.0"
44
-
45
- spec.add_development_dependency "bundler"
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.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Durand
@@ -37,20 +37,6 @@ dependencies:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 1.3.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'
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