patient_http-sidekiq 1.0.0 → 1.0.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: 5d2f470219dae6e479974adecec97231a42918686c415b3d601c1803274cdb06
4
- data.tar.gz: b8af3ece14b9c58032153ee2870c7122ae30b460894aad31bbd018f879e79da3
3
+ metadata.gz: bcb233e85930e0c27c9d950b3fee8621cb78d72534f128e2d13bb5072da6a95b
4
+ data.tar.gz: 86f1b667bb854573f4123d1d35895aea0d6159a21f8026c1313877a61ae93b7a
5
5
  SHA512:
6
- metadata.gz: 9f78b1ade928fc188d3e48247fe6a6a2a3891470b820b24e912737cdea8ad8ce1bbb3b0324e3dc0ab7417cf0c5142db9045b3ee24064e7d4d54de45ea191b126
7
- data.tar.gz: 8050fbbbaa96eb45217ef7df4c1fb554f3b79fe8440156ed09e31e42d290fdc5cf849ebf20be2eb03dcf4b35a72b827d740e41606412cd1a987ea60ce1333b87
6
+ metadata.gz: 69fc0eece8eb9075ee02ee3a8ef5422017f08c7bb06206b8309cb0174f5c28943ac489c0b9b58004524b301007f2e1ed6355e2dcd0c5a0e4d855eaf027e6d1cf
7
+ data.tar.gz: 2a24b218cd8a33687b141a0ed1a05e08e00e01da7d3fce9fe4b94bdb560c39a5d9d931caa8f3116ad63b03dc94089cac30a73e00ba34ac31443903ca115c25b2
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ 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.0.1
8
+
9
+ ### Fixed
10
+
11
+ - Ensure `PatientHttp::Sidekiq` is automatically registered as the HTTP processor on a process not running the Sidekiq server. This gem will now auto register itself on a client process either by calling `PatientHttp::Sidekiq.configure` or `PatientHttp::Sidekiq.register_handler` directly.
12
+
7
13
  ## 1.0.0
8
14
 
9
15
  ### Added
data/README.md CHANGED
@@ -46,7 +46,17 @@ The async processor runs in a dedicated thread within your Sidekiq process, usin
46
46
 
47
47
  ## Quick Start
48
48
 
49
- ### 1. Create a Callback Service
49
+ ### 1. Configure The Gem
50
+
51
+ Configure the gem in an initializer (see the Configuration section below for all available options):
52
+
53
+ ```ruby
54
+ PatientHttp::Sidekiq.configure do |config|
55
+ config.max_connections = 256
56
+ end
57
+ ```
58
+
59
+ ### 2. Create a Callback Service
50
60
 
51
61
  Define a callback service class with `on_complete` and `on_error` methods:
52
62
 
@@ -69,7 +79,7 @@ class FetchDataCallback
69
79
  end
70
80
  ```
71
81
 
72
- ### 2. Make HTTP Requests
82
+ ### 3. Make HTTP Requests
73
83
 
74
84
  Make HTTP requests from anywhere in your code using `PatientHttp`:
75
85
 
@@ -82,7 +92,7 @@ PatientHttp.get(
82
92
  )
83
93
  ```
84
94
 
85
- ### 3. That's It!
95
+ ### 4. That's It!
86
96
 
87
97
  The request will be enqueued as a Sidekiq job and passed to a [PatientHttp](https://github.com/bdurand/patient_http) processor to execute asynchronously. When the HTTP request completes, your callback's `on_complete` method is executed in another Sidekiq job.
88
98
 
@@ -451,6 +461,9 @@ end
451
461
 
452
462
  See the [Configuration](lib/patient_http/sidekiq/configuration.rb) class for all available options.
453
463
 
464
+ > [!NOTE]
465
+ > You **must** call `PatientHttp::Sidekiq.configure` or `PatientHttp::Sidekiq.register_handler` in order to register the request handler and start processing requests. If you do not call either method, you will get errors making HTTP requests with `PatientHttp.execute`.
466
+
454
467
  ### Tuning Tips
455
468
 
456
469
  - `max_connections`: Adjust this based on your system's resources. Each connection uses memory and file descriptors. A tuned system with sufficient resources can handle thousands of concurrent connections.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -97,6 +97,7 @@ module PatientHttp
97
97
  def configure
98
98
  configuration = Configuration.new
99
99
  yield(configuration) if block_given?
100
+ register_handler
100
101
  @configuration = configuration
101
102
  end
102
103
 
@@ -231,6 +232,21 @@ module PatientHttp
231
232
  request_id
232
233
  end
233
234
 
235
+ # Register Sidekiq as the request handler for processing HTTP requests. This is called
236
+ # automatically when the processor starts or you call PatientHttp::Sidekiq.configure.
237
+ def register_handler
238
+ @request_handler ||= lambda do |request:, callback:, raise_error_responses:, callback_args:|
239
+ execute(
240
+ request,
241
+ callback: callback,
242
+ raise_error_responses: raise_error_responses,
243
+ callback_args: callback_args
244
+ )
245
+ end
246
+
247
+ PatientHttp.register_handler(@request_handler)
248
+ end
249
+
234
250
  # Start the processor
235
251
  #
236
252
  # @return [void]
@@ -244,16 +260,7 @@ module PatientHttp
244
260
  end
245
261
  @processor.start
246
262
 
247
- @request_handler ||= lambda do |request:, callback:, raise_error_responses:, callback_args:|
248
- execute(
249
- request,
250
- callback: callback,
251
- raise_error_responses: raise_error_responses,
252
- callback_args: callback_args
253
- )
254
- end
255
-
256
- PatientHttp.register_handler(@request_handler)
263
+ register_handler
257
264
  end
258
265
 
259
266
  # Signal the processor to drain (stop accepting new requests)
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.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Durand