Class: PatientHttp::Sidekiq::Configuration
- Inherits:
-
Configuration
- Object
- Configuration
- PatientHttp::Sidekiq::Configuration
- Defined in:
- lib/patient_http/sidekiq/configuration.rb
Overview
Configuration for the Sidekiq integration.
Wraps PatientHttp::Configuration with Sidekiq-aware defaults and adds Sidekiq-specific options like worker queue/retry settings.
Access the underlying pool configuration via the http_pool attribute.
Constant Summary collapse
- DEFAULT_PAYLOAD_STORE_THRESHOLD =
Default threshold in bytes above which payloads are stored externally
64 * 1024
Instance Attribute Summary collapse
-
#direct_execution ⇒ Boolean
Whether requests execute directly on a processor running in the current process instead of being enqueued through Sidekiq.
-
#heartbeat_interval ⇒ Numeric
Heartbeat update interval in seconds.
-
#observers ⇒ Array<PatientHttp::ProcessorObserver>
readonly
Registered processor observers Observers will be registered with the processor when it is started, allowing them to receive lifecycle callbacks for PatientHttp requests.
-
#orphan_threshold ⇒ Numeric
Orphan detection threshold in seconds.
-
#payload_store_threshold ⇒ Integer
Size threshold in bytes for external payload storage.
-
#sidekiq_options ⇒ Hash?
Sidekiq options to apply to RequestWorker and CallbackWorker.
Instance Method Summary collapse
-
#direct_execution? ⇒ Boolean
Check if direct execution is enabled.
-
#initialize(heartbeat_interval: 60, orphan_threshold: 300, sidekiq_options: nil, payload_store_threshold: DEFAULT_PAYLOAD_STORE_THRESHOLD, on_retries_exhausted: nil, direct_execution: true, **pool_options) ⇒ Configuration
constructor
Initializes a new Configuration with the specified options.
-
#on_retries_exhausted(&block) ⇒ #call?
Handler invoked when a CallbackWorker job exhausts all retries.
-
#on_retries_exhausted=(value) ⇒ Object
Set the on_retries_exhausted handler.
-
#to_h ⇒ Hash
Convert to hash for inspection.
Constructor Details
#initialize(heartbeat_interval: 60, orphan_threshold: 300, sidekiq_options: nil, payload_store_threshold: DEFAULT_PAYLOAD_STORE_THRESHOLD, on_retries_exhausted: nil, direct_execution: true, **pool_options) ⇒ Configuration
Initializes a new Configuration with the specified options.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/patient_http/sidekiq/configuration.rb', line 63 def initialize( heartbeat_interval: 60, orphan_threshold: 300, sidekiq_options: nil, payload_store_threshold: DEFAULT_PAYLOAD_STORE_THRESHOLD, on_retries_exhausted: nil, direct_execution: true, ** ) [:shutdown_timeout] ||= (::Sidekiq.default_configuration[:timeout] || 25) - 2 [:logger] ||= ::Sidekiq.logger super(**) @observers = [] self. = self.heartbeat_interval = heartbeat_interval self.orphan_threshold = orphan_threshold self.payload_store_threshold = payload_store_threshold || DEFAULT_PAYLOAD_STORE_THRESHOLD self.on_retries_exhausted = on_retries_exhausted self.direct_execution = direct_execution end |
Instance Attribute Details
#direct_execution ⇒ Boolean
Returns Whether requests execute directly on a processor running in the current process instead of being enqueued through Sidekiq.
29 30 31 |
# File 'lib/patient_http/sidekiq/configuration.rb', line 29 def direct_execution @direct_execution end |
#heartbeat_interval ⇒ Numeric
Returns Heartbeat update interval in seconds.
22 23 24 |
# File 'lib/patient_http/sidekiq/configuration.rb', line 22 def heartbeat_interval @heartbeat_interval end |
#observers ⇒ Array<PatientHttp::ProcessorObserver> (readonly)
Returns Registered processor observers Observers will be registered with the processor when it is started, allowing them to receive lifecycle callbacks for PatientHttp requests.
50 51 52 |
# File 'lib/patient_http/sidekiq/configuration.rb', line 50 def observers @observers end |
#orphan_threshold ⇒ Numeric
Returns Orphan detection threshold in seconds.
19 20 21 |
# File 'lib/patient_http/sidekiq/configuration.rb', line 19 def orphan_threshold @orphan_threshold end |
#payload_store_threshold ⇒ Integer
Returns Size threshold in bytes for external payload storage.
16 17 18 |
# File 'lib/patient_http/sidekiq/configuration.rb', line 16 def payload_store_threshold @payload_store_threshold end |
#sidekiq_options ⇒ Hash?
Returns Sidekiq options to apply to RequestWorker and CallbackWorker.
25 26 27 |
# File 'lib/patient_http/sidekiq/configuration.rb', line 25 def @sidekiq_options end |
Instance Method Details
#direct_execution? ⇒ Boolean
Check if direct execution is enabled.
169 170 171 |
# File 'lib/patient_http/sidekiq/configuration.rb', line 169 def direct_execution? @direct_execution end |
#on_retries_exhausted ⇒ #call? #on_retries_exhausted {|error| ... } ⇒ #call?
Returns Handler invoked when a CallbackWorker job exhausts all retries.
39 40 41 42 43 44 45 |
# File 'lib/patient_http/sidekiq/configuration.rb', line 39 def on_retries_exhausted(&block) if block @on_retries_exhausted = block else @on_retries_exhausted end end |
#on_retries_exhausted=(value) ⇒ Object
Set the on_retries_exhausted handler.
This handler is called when a CallbackWorker job exhausts all retries. It receives the same arguments as the on_error callback.
93 94 95 96 97 98 99 |
# File 'lib/patient_http/sidekiq/configuration.rb', line 93 def on_retries_exhausted=(value) if value && !value.respond_to?(:call) raise ArgumentError.new("on_retries_exhausted must respond to #call, got: #{value.class}") end @on_retries_exhausted = value end |
#to_h ⇒ Hash
Convert to hash for inspection
175 176 177 178 179 180 181 182 183 184 |
# File 'lib/patient_http/sidekiq/configuration.rb', line 175 def to_h super.merge( "payload_store_threshold" => payload_store_threshold, "heartbeat_interval" => heartbeat_interval, "orphan_threshold" => orphan_threshold, "sidekiq_options" => , "direct_execution" => direct_execution, "on_retries_exhausted" => on_retries_exhausted ? "defined" : nil ) end |