Class: Legion::Extensions::Llm::Inventory::Identity::InstanceKey
- Inherits:
-
Data
- Object
- Data
- Legion::Extensions::Llm::Inventory::Identity::InstanceKey
- Defined in:
- lib/legion/extensions/llm/inventory/identity.rb
Overview
A mandatory, immutable provider_family + instance_id pair. Provider family alone is never executable; two instances of the same provider are independent targets. See section 8.1.
instance_id is the operator's CONFIG NAME — the identity the router
keys settings lookups (instances.
Instance Attribute Summary collapse
-
#instance_id ⇒ Object
readonly
Returns the value of attribute instance_id.
-
#physical_id ⇒ Object
readonly
Returns the value of attribute physical_id.
-
#provider_family ⇒ Object
readonly
Returns the value of attribute provider_family.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Identity is exactly (provider_family, instance_id).
- #hash ⇒ Object
-
#initialize(provider_family:, instance_id:, physical_id: nil) ⇒ InstanceKey
constructor
A new instance of InstanceKey.
Constructor Details
#initialize(provider_family:, instance_id:, physical_id: nil) ⇒ InstanceKey
Returns a new instance of InstanceKey.
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 113 def initialize(provider_family:, instance_id:, physical_id: nil) family = Identity.normalize_text(value: provider_family, field: :provider_family).downcase raise Errors::ValidationError, 'provider_family must match /\A[a-z][a-z0-9_]*\z/' unless family.match?(/\A[a-z][a-z0-9_]*\z/) instance = Identity.normalize_text(value: instance_id, field: :instance_id) raise Errors::ValidationError, 'instance_id must not be the reserved value "default"' if instance == 'default' physical = physical_id.nil? ? nil : Identity.normalize_text(value: physical_id, field: :physical_id) super(provider_family: family.to_sym, instance_id: instance, physical_id: physical) end |
Instance Attribute Details
#instance_id ⇒ Object (readonly)
Returns the value of attribute instance_id
112 113 114 |
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 112 def instance_id @instance_id end |
#physical_id ⇒ Object (readonly)
Returns the value of attribute physical_id
112 113 114 |
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 112 def physical_id @physical_id end |
#provider_family ⇒ Object (readonly)
Returns the value of attribute provider_family
112 113 114 |
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 112 def provider_family @provider_family end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Identity is exactly (provider_family, instance_id). The secondary physical_id never affects equality, hashing, or registry-scope identity.
128 129 130 |
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 128 def ==(other) other.is_a?(self.class) && other.provider_family == provider_family && other.instance_id == instance_id end |
#hash ⇒ Object
133 134 135 |
# File 'lib/legion/extensions/llm/inventory/identity.rb', line 133 def hash [self.class, provider_family, instance_id].hash end |