Class: Mxup::WaitSpec
- Inherits:
-
Struct
- Object
- Struct
- Mxup::WaitSpec
- Defined in:
- lib/mxup/config.rb
Overview
A readiness check attached to a window.
Constant Summary collapse
- CHECK_TYPES =
%w[tcp http path script].freeze
- OPTION_KEYS =
%w[timeout interval label].freeze
- ALLOWED_KEYS =
(CHECK_TYPES + OPTION_KEYS).freeze
Instance Attribute Summary collapse
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#label ⇒ Object
Returns the value of attribute label.
-
#target ⇒ Object
Returns the value of attribute target.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Attribute Details
#interval ⇒ Object
Returns the value of attribute interval
387 388 389 |
# File 'lib/mxup/config.rb', line 387 def interval @interval end |
#label ⇒ Object
Returns the value of attribute label
387 388 389 |
# File 'lib/mxup/config.rb', line 387 def label @label end |
#target ⇒ Object
Returns the value of attribute target
387 388 389 |
# File 'lib/mxup/config.rb', line 387 def target @target end |
#timeout ⇒ Object
Returns the value of attribute timeout
387 388 389 |
# File 'lib/mxup/config.rb', line 387 def timeout @timeout end |
#type ⇒ Object
Returns the value of attribute type
387 388 389 |
# File 'lib/mxup/config.rb', line 387 def type @type end |
Class Method Details
.parse(raw) ⇒ Object
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/mxup/config.rb', line 392 def self.parse(raw) case raw when nil nil when String new(type: :tcp, target: raw, timeout: nil, interval: 2, label: raw) when Hash extra = raw.keys.map(&:to_s) - ALLOWED_KEYS unless extra.empty? raise ArgumentError, "wait_for: unknown key(s) #{extra.map(&:inspect).join(', ')} " \ "(allowed: #{ALLOWED_KEYS.join(', ')})" end found = CHECK_TYPES & raw.keys unless found.size == 1 raise ArgumentError, "wait_for must specify exactly one of: #{CHECK_TYPES.join(', ')}" end type = found.first target = raw[type] default_label = type == 'script' ? 'readiness check' : target new( type: type.to_sym, target: target, timeout: raw['timeout'], interval: raw['interval'] || 2, label: raw['label'] || default_label ) else raise ArgumentError, "wait_for must be a string or hash, got #{raw.class}" end end |