Class: Zeridion::Flare::Worker::Configuration
- Inherits:
-
Object
- Object
- Zeridion::Flare::Worker::Configuration
- Defined in:
- lib/zeridion_flare/worker/configuration.rb
Overview
Resolved worker configuration. One bootstrap object — there is no separate "Configuration class vs Worker class" split; Worker.new builds this from its keyword args and normalizes defaults here.
Constant Summary collapse
- DEFAULT_QUEUES =
["default"].freeze
- DEFAULT_CONCURRENCY =
10- DEFAULT_POLL_INTERVAL_S =
2.0- DEFAULT_TIMEOUT_S =
1800- DEFAULT_MAX_ATTEMPTS =
3- DEFAULT_SHUTDOWN_GRACE_S =
30.0- DEFAULT_POLL_READ_TIMEOUT_S =
The worker owns its own HTTP client with a poll read-timeout > 30 s so the ~30 s long-poll never trips the client's own read deadline (decision D5). 45 s leaves margin for the server's long-poll plus slack.
45.0- DEFAULT_RPC_TIMEOUT_S =
Heartbeat / ack use a short read-timeout (these are quick round-trips).
15.0- HEARTBEAT_FLOOR_MS =
Floor on the heartbeat cadence in milliseconds (10 s, per the protocol). Shrinkable for deterministic tests via FLARE_HEARTBEAT_MIN_MS (test seam D8) or the explicit heartbeat_min_ms: keyword.
10_000
Instance Attribute Summary collapse
-
#concurrency ⇒ Object
readonly
Returns the value of attribute concurrency.
-
#default_max_attempts ⇒ Object
readonly
Returns the value of attribute default_max_attempts.
-
#default_timeout_s ⇒ Object
readonly
Returns the value of attribute default_timeout_s.
-
#heartbeat_min_ms ⇒ Object
readonly
Returns the value of attribute heartbeat_min_ms.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#poll_interval_s ⇒ Object
readonly
Returns the value of attribute poll_interval_s.
-
#poll_read_timeout_s ⇒ Object
readonly
Returns the value of attribute poll_read_timeout_s.
-
#queues ⇒ Object
readonly
Returns the value of attribute queues.
-
#rpc_timeout_s ⇒ Object
readonly
Returns the value of attribute rpc_timeout_s.
-
#shutdown_grace_s ⇒ Object
readonly
Returns the value of attribute shutdown_grace_s.
Instance Method Summary collapse
-
#explicit_queues? ⇒ Boolean
Whether the user pinned an explicit queue list (vs deriving from jobs).
-
#initialize(queues: nil, concurrency: DEFAULT_CONCURRENCY, poll_interval_s: DEFAULT_POLL_INTERVAL_S, default_timeout_s: DEFAULT_TIMEOUT_S, default_max_attempts: DEFAULT_MAX_ATTEMPTS, shutdown_grace_s: DEFAULT_SHUTDOWN_GRACE_S, poll_read_timeout_s: DEFAULT_POLL_READ_TIMEOUT_S, rpc_timeout_s: DEFAULT_RPC_TIMEOUT_S, hostname: nil, logger: nil, heartbeat_min_ms: nil) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(queues: nil, concurrency: DEFAULT_CONCURRENCY, poll_interval_s: DEFAULT_POLL_INTERVAL_S, default_timeout_s: DEFAULT_TIMEOUT_S, default_max_attempts: DEFAULT_MAX_ATTEMPTS, shutdown_grace_s: DEFAULT_SHUTDOWN_GRACE_S, poll_read_timeout_s: DEFAULT_POLL_READ_TIMEOUT_S, rpc_timeout_s: DEFAULT_RPC_TIMEOUT_S, hostname: nil, logger: nil, heartbeat_min_ms: nil) ⇒ Configuration
Returns a new instance of Configuration.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 46 def initialize( queues: nil, concurrency: DEFAULT_CONCURRENCY, poll_interval_s: DEFAULT_POLL_INTERVAL_S, default_timeout_s: DEFAULT_TIMEOUT_S, default_max_attempts: DEFAULT_MAX_ATTEMPTS, shutdown_grace_s: DEFAULT_SHUTDOWN_GRACE_S, poll_read_timeout_s: DEFAULT_POLL_READ_TIMEOUT_S, rpc_timeout_s: DEFAULT_RPC_TIMEOUT_S, hostname: nil, logger: nil, heartbeat_min_ms: nil ) @queues = normalize_queues(queues) @concurrency = [concurrency.to_i, 1].max @poll_interval_s = poll_interval_s.to_f @default_timeout_s = [default_timeout_s.to_i, 1].max @default_max_attempts = [default_max_attempts.to_i, 1].max @shutdown_grace_s = shutdown_grace_s.to_f @poll_read_timeout_s = poll_read_timeout_s.to_f @rpc_timeout_s = rpc_timeout_s.to_f @hostname = hostname @logger = logger @heartbeat_min_ms = resolve_heartbeat_min_ms(heartbeat_min_ms) end |
Instance Attribute Details
#concurrency ⇒ Object (readonly)
Returns the value of attribute concurrency.
29 30 31 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 29 def concurrency @concurrency end |
#default_max_attempts ⇒ Object (readonly)
Returns the value of attribute default_max_attempts.
29 30 31 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 29 def default_max_attempts @default_max_attempts end |
#default_timeout_s ⇒ Object (readonly)
Returns the value of attribute default_timeout_s.
29 30 31 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 29 def default_timeout_s @default_timeout_s end |
#heartbeat_min_ms ⇒ Object (readonly)
Returns the value of attribute heartbeat_min_ms.
29 30 31 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 29 def heartbeat_min_ms @heartbeat_min_ms end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
29 30 31 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 29 def hostname @hostname end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
29 30 31 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 29 def logger @logger end |
#poll_interval_s ⇒ Object (readonly)
Returns the value of attribute poll_interval_s.
29 30 31 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 29 def poll_interval_s @poll_interval_s end |
#poll_read_timeout_s ⇒ Object (readonly)
Returns the value of attribute poll_read_timeout_s.
29 30 31 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 29 def poll_read_timeout_s @poll_read_timeout_s end |
#queues ⇒ Object (readonly)
Returns the value of attribute queues.
29 30 31 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 29 def queues @queues end |
#rpc_timeout_s ⇒ Object (readonly)
Returns the value of attribute rpc_timeout_s.
29 30 31 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 29 def rpc_timeout_s @rpc_timeout_s end |
#shutdown_grace_s ⇒ Object (readonly)
Returns the value of attribute shutdown_grace_s.
29 30 31 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 29 def shutdown_grace_s @shutdown_grace_s end |
Instance Method Details
#explicit_queues? ⇒ Boolean
Whether the user pinned an explicit queue list (vs deriving from jobs).
73 74 75 |
# File 'lib/zeridion_flare/worker/configuration.rb', line 73 def explicit_queues? !@queues.nil? end |