Class: PatientHttp::SolidQueue::Configuration
- Inherits:
-
Configuration
- Object
- Configuration
- PatientHttp::SolidQueue::Configuration
- Defined in:
- lib/patient_http/solid_queue/configuration.rb
Overview
Configuration for the Solid Queue Async HTTP gem.
Wraps PatientHttp::Configuration with Solid Queue-aware defaults and adds Solid Queue-specific options like queue name settings.
Constant Summary collapse
- DEFAULT_PAYLOAD_STORE_THRESHOLD =
Default threshold in bytes above which payloads are stored externally.
64 * 1024
- SHUTDOWN_TIMEOUT_BUFFER =
Buffer in seconds subtracted from SolidQueue.shutdown_timeout to derive the default shutdown_timeout for this gem’s connection pool.
2
Instance Attribute Summary collapse
-
#heartbeat_interval ⇒ Numeric
Heartbeat update interval in seconds.
-
#orphan_threshold ⇒ Numeric
Orphan detection threshold in seconds.
-
#payload_store_threshold ⇒ Integer
Size threshold in bytes for external payload storage.
-
#queue_name ⇒ String?
Queue name for RequestJob and CallbackJob.
Instance Method Summary collapse
-
#initialize(heartbeat_interval: 60, orphan_threshold: 300, queue_name: nil, payload_store_threshold: DEFAULT_PAYLOAD_STORE_THRESHOLD, on_retries_exhausted: nil, **pool_options) ⇒ Configuration
constructor
A new instance of Configuration.
-
#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
Configuration as a hash for logging/inspection.
Constructor Details
#initialize(heartbeat_interval: 60, orphan_threshold: 300, queue_name: nil, payload_store_threshold: DEFAULT_PAYLOAD_STORE_THRESHOLD, on_retries_exhausted: nil, **pool_options) ⇒ Configuration
Returns a new instance of Configuration.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/patient_http/solid_queue/configuration.rb', line 51 def initialize( heartbeat_interval: 60, orphan_threshold: 300, queue_name: nil, payload_store_threshold: DEFAULT_PAYLOAD_STORE_THRESHOLD, on_retries_exhausted: nil, ** ) if ::SolidQueue.shutdown_timeout [:shutdown_timeout] ||= [::SolidQueue.shutdown_timeout - SHUTDOWN_TIMEOUT_BUFFER, 1].max end [:user_agent] ||= "SolidQueue-AsyncHttp" [:logger] ||= (defined?(SolidQueue.logger) ? SolidQueue.logger : nil) super(**) self.queue_name = queue_name 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 end |
Instance Attribute Details
#heartbeat_interval ⇒ Numeric
Returns Heartbeat update interval in seconds.
20 21 22 |
# File 'lib/patient_http/solid_queue/configuration.rb', line 20 def heartbeat_interval @heartbeat_interval end |
#orphan_threshold ⇒ Numeric
Returns Orphan detection threshold in seconds.
17 18 19 |
# File 'lib/patient_http/solid_queue/configuration.rb', line 17 def orphan_threshold @orphan_threshold end |
#payload_store_threshold ⇒ Integer
Returns Size threshold in bytes for external payload storage.
14 15 16 |
# File 'lib/patient_http/solid_queue/configuration.rb', line 14 def payload_store_threshold @payload_store_threshold end |
#queue_name ⇒ String?
Returns Queue name for RequestJob and CallbackJob.
23 24 25 |
# File 'lib/patient_http/solid_queue/configuration.rb', line 23 def queue_name @queue_name end |
Instance Method Details
#on_retries_exhausted ⇒ #call? #on_retries_exhausted {|error| ... } ⇒ #call?
Returns Handler invoked when a CallbackWorker job exhausts all retries.
33 34 35 36 37 38 39 |
# File 'lib/patient_http/solid_queue/configuration.rb', line 33 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.
109 110 111 112 113 114 115 |
# File 'lib/patient_http/solid_queue/configuration.rb', line 109 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
Returns configuration as a hash for logging/inspection.
118 119 120 121 122 123 124 125 126 |
# File 'lib/patient_http/solid_queue/configuration.rb', line 118 def to_h super.merge( "payload_store_threshold" => payload_store_threshold, "heartbeat_interval" => heartbeat_interval, "orphan_threshold" => orphan_threshold, "queue_name" => queue_name, "on_retries_exhausted" => on_retries_exhausted ? "defined" : nil ) end |