Class: Legion::Extensions::Llm::Inventory::Publisher

Inherits:
Object
  • Object
show all
Includes:
Logging::Helper
Defined in:
lib/legion/extensions/llm/inventory/publisher.rb

Overview

Provider-facing direct wrapper over the local Registry. It constructs and validates the exact InstanceKey from its fixed provider family and delegates to the registry with the exact kwargs. It does no retries, selection, scheduling, defaulting, provider discovery, or exception swallowing beyond the explicitly injected, best-effort post-commit old-coordinator projection. See phase-1-lex-llm-additive.md section 13.1.

Instance Method Summary collapse

Constructor Details

#initialize(provider_family:, registry: Registry, compatibility_adapter: nil) ⇒ Publisher

Returns a new instance of Publisher.



21
22
23
24
25
# File 'lib/legion/extensions/llm/inventory/publisher.rb', line 21

def initialize(provider_family:, registry: Registry, compatibility_adapter: nil)
  @provider_family = provider_family
  @registry = registry
  @compatibility_adapter = compatibility_adapter
end

Instance Method Details

#activate_instance_snapshot(instance_id:, publisher_token:, offerings:, sequence:, probe_token:, physical_id: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists



44
45
46
47
48
49
50
51
# File 'lib/legion/extensions/llm/inventory/publisher.rb', line 44

def activate_instance_snapshot(instance_id:, publisher_token:, offerings:, sequence:, probe_token:, physical_id: nil) # rubocop:disable Metrics/ParameterLists
  key = instance_key(instance_id: instance_id, physical_id: physical_id)
  result = @registry.activate_instance_snapshot(
    publisher_token: publisher_token, instance_key: key, offerings: offerings,
    sequence: sequence, probe_token: probe_token
  )
  sync_applied(key, result)
end

#claim_instance(instance_id:, callable:, probe_request_handle:, physical_id: nil) ⇒ Object

Every instance operation takes instance_id: — the operator's CONFIG NAME (the identity the router keys by) — and an optional physical_id: carrying the physical/derived id (host:port/ak) for dedup and diagnostics only. See Identity::InstanceKey.



31
32
33
34
35
36
# File 'lib/legion/extensions/llm/inventory/publisher.rb', line 31

def claim_instance(instance_id:, callable:, probe_request_handle:, physical_id: nil)
  key = instance_key(instance_id: instance_id, physical_id: physical_id)
  token = @registry.claim_instance(instance_key: key, callable: callable, probe_request_handle: probe_request_handle)
  sync_compatibility(key, :claimed)
  token
end

#readiness_failed(instance_id:, probe_token:, reason:, physical_id: nil) ⇒ Object



66
67
68
69
# File 'lib/legion/extensions/llm/inventory/publisher.rb', line 66

def readiness_failed(instance_id:, probe_token:, reason:, physical_id: nil)
  key = instance_key(instance_id: instance_id, physical_id: physical_id)
  sync_applied(key, @registry.readiness_failed(instance_key: key, probe_token: probe_token, reason: reason))
end

#readiness_probe_started(instance_id:, publisher_token:, physical_id: nil) ⇒ Object



38
39
40
41
42
# File 'lib/legion/extensions/llm/inventory/publisher.rb', line 38

def readiness_probe_started(instance_id:, publisher_token:, physical_id: nil)
  @registry.readiness_probe_started(
    instance_key: instance_key(instance_id: instance_id, physical_id: physical_id), publisher_token: publisher_token
  )
end

#readiness_succeeded(instance_id:, probe_token:, physical_id: nil) ⇒ Object



61
62
63
64
# File 'lib/legion/extensions/llm/inventory/publisher.rb', line 61

def readiness_succeeded(instance_id:, probe_token:, physical_id: nil)
  key = instance_key(instance_id: instance_id, physical_id: physical_id)
  sync_applied(key, @registry.readiness_succeeded(instance_key: key, probe_token: probe_token))
end

#remove_instance(instance_id:, publisher_token:, physical_id: nil) ⇒ Object



71
72
73
74
# File 'lib/legion/extensions/llm/inventory/publisher.rb', line 71

def remove_instance(instance_id:, publisher_token:, physical_id: nil)
  key = instance_key(instance_id: instance_id, physical_id: physical_id)
  sync_applied(key, @registry.remove_instance(instance_key: key, publisher_token: publisher_token))
end

#replace_instance_snapshot(instance_id:, publisher_token:, offerings:, sequence:, physical_id: nil) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/legion/extensions/llm/inventory/publisher.rb', line 53

def replace_instance_snapshot(instance_id:, publisher_token:, offerings:, sequence:, physical_id: nil)
  key = instance_key(instance_id: instance_id, physical_id: physical_id)
  result = @registry.replace_instance_snapshot(
    publisher_token: publisher_token, instance_key: key, offerings: offerings, sequence: sequence
  )
  sync_applied(key, result)
end

#snapshotObject



76
77
78
# File 'lib/legion/extensions/llm/inventory/publisher.rb', line 76

def snapshot
  @registry.snapshot
end