Class: Legion::Extensions::Llm::Inventory::AvailabilityFact
- Inherits:
-
Data
- Object
- Data
- Legion::Extensions::Llm::Inventory::AvailabilityFact
- Defined in:
- lib/legion/extensions/llm/inventory/records.rb
Overview
The availability state of an exact instance. Carries no cooldown, half-open, latency, success-count, or clock-expiry field. See 10.4.
Instance Attribute Summary collapse
-
#availability_revision ⇒ Object
readonly
Returns the value of attribute availability_revision.
-
#last_probe_completed_at ⇒ Object
readonly
Returns the value of attribute last_probe_completed_at.
-
#last_probe_outcome ⇒ Object
readonly
Returns the value of attribute last_probe_outcome.
-
#last_probe_started_at ⇒ Object
readonly
Returns the value of attribute last_probe_started_at.
-
#observed_at ⇒ Object
readonly
Returns the value of attribute observed_at.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#unavailable_revision ⇒ Object
readonly
Returns the value of attribute unavailable_revision.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ AvailabilityFact
constructor
A new instance of AvailabilityFact.
- #validate_probe_telemetry!(started_at, completed_at, outcome) ⇒ Object
- #validate_unavailable_revision!(state, availability_revision, unavailable_revision) ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ AvailabilityFact
Returns a new instance of AvailabilityFact.
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 381 def initialize(**kwargs) kwargs = { last_probe_started_at: nil, last_probe_completed_at: nil, last_probe_outcome: nil, unavailable_revision: nil }.merge(kwargs) RecordSupport.check_unknown_kwargs!(kwargs: kwargs, members: self.class.members) state = kwargs[:state] availability_revision = kwargs[:availability_revision] unavailable_revision = kwargs[:unavailable_revision] raise Errors::ValidationError, 'state must be a Taxonomies::AVAILABILITY_STATES value' unless Taxonomies::AVAILABILITY_STATES.include?(state) raise Errors::ValidationError, 'source must be a Taxonomies::AVAILABILITY_SOURCES value' unless Taxonomies::AVAILABILITY_SOURCES.include?(kwargs[:source]) RecordSupport.nonnegative_integer(value: availability_revision, field: :availability_revision) validate_unavailable_revision!(state, availability_revision, unavailable_revision) resolved_outcome = validate_probe_telemetry!( kwargs[:last_probe_started_at], kwargs[:last_probe_completed_at], kwargs[:last_probe_outcome] ) super( state: state, availability_revision: availability_revision, source: kwargs[:source], reason: RecordSupport.sanitized_reason(value: kwargs[:reason], field: :reason), observed_at: RecordSupport.optional_time(value: kwargs[:observed_at], field: :observed_at), last_probe_started_at: RecordSupport.optional_time(value: kwargs[:last_probe_started_at], field: :last_probe_started_at), last_probe_completed_at: RecordSupport.optional_time(value: kwargs[:last_probe_completed_at], field: :last_probe_completed_at), last_probe_outcome: resolved_outcome, unavailable_revision: unavailable_revision ) end |
Instance Attribute Details
#availability_revision ⇒ Object (readonly)
Returns the value of attribute availability_revision
377 378 379 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 377 def availability_revision @availability_revision end |
#last_probe_completed_at ⇒ Object (readonly)
Returns the value of attribute last_probe_completed_at
377 378 379 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 377 def last_probe_completed_at @last_probe_completed_at end |
#last_probe_outcome ⇒ Object (readonly)
Returns the value of attribute last_probe_outcome
377 378 379 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 377 def last_probe_outcome @last_probe_outcome end |
#last_probe_started_at ⇒ Object (readonly)
Returns the value of attribute last_probe_started_at
377 378 379 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 377 def last_probe_started_at @last_probe_started_at end |
#observed_at ⇒ Object (readonly)
Returns the value of attribute observed_at
377 378 379 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 377 def observed_at @observed_at end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason
377 378 379 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 377 def reason @reason end |
#source ⇒ Object (readonly)
Returns the value of attribute source
377 378 379 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 377 def source @source end |
#state ⇒ Object (readonly)
Returns the value of attribute state
377 378 379 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 377 def state @state end |
#unavailable_revision ⇒ Object (readonly)
Returns the value of attribute unavailable_revision
377 378 379 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 377 def unavailable_revision @unavailable_revision end |
Instance Method Details
#validate_probe_telemetry!(started_at, completed_at, outcome) ⇒ Object
420 421 422 423 424 425 426 427 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 420 def validate_probe_telemetry!(started_at, completed_at, outcome) return nil if outcome.nil? raise Errors::ValidationError, 'last_probe_outcome must be nil, :success, or :failure' unless Taxonomies::PROBE_OUTCOMES.include?(outcome) raise Errors::ValidationError, 'a non-nil last_probe_outcome requires both probe timestamps' unless started_at.is_a?(::Time) && completed_at.is_a?(::Time) raise Errors::ValidationError, 'probe completion cannot precede start' if completed_at < started_at outcome end |
#validate_unavailable_revision!(state, availability_revision, unavailable_revision) ⇒ Object
412 413 414 415 416 417 418 |
# File 'lib/legion/extensions/llm/inventory/records.rb', line 412 def validate_unavailable_revision!(state, availability_revision, unavailable_revision) if state == :unavailable raise Errors::ValidationError, 'unavailable state requires unavailable_revision == availability_revision' unless unavailable_revision == availability_revision elsif !unavailable_revision.nil? raise Errors::ValidationError, 'non-unavailable state requires unavailable_revision: nil' end end |