Class: Legion::Gaia::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/gaia/registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry.



8
9
10
11
12
13
# File 'lib/legion/gaia/registry.rb', line 8

def initialize
  @runner_instances = {}
  @phase_handlers = {}
  @discovery = {}
  @discovered = false
end

Instance Attribute Details

#discoveryObject (readonly)

Returns the value of attribute discovery.



6
7
8
# File 'lib/legion/gaia/registry.rb', line 6

def discovery
  @discovery
end

#phase_handlersObject (readonly)

Returns the value of attribute phase_handlers.



6
7
8
# File 'lib/legion/gaia/registry.rb', line 6

def phase_handlers
  @phase_handlers
end

#runner_instancesObject (readonly)

Returns the value of attribute runner_instances.



6
7
8
# File 'lib/legion/gaia/registry.rb', line 6

def runner_instances
  @runner_instances
end

Instance Method Details

#discoverObject



15
16
17
18
19
20
21
22
23
# File 'lib/legion/gaia/registry.rb', line 15

def discover
  @runner_instances = build_runner_instances
  @phase_handlers = PhaseWiring.build_phase_handlers(@runner_instances)
  @discovery = PhaseWiring.discover_available_extensions
  @discovered = true

  log_info "[gaia:registry] discovered: #{loaded_count}/#{total_count} extensions, " \
           "#{wired_count} phases wired"
end

#ensure_wiredObject



35
36
37
# File 'lib/legion/gaia/registry.rb', line 35

def ensure_wired
  discover unless @discovered
end

#loaded_countObject



43
44
45
# File 'lib/legion/gaia/registry.rb', line 43

def loaded_count
  @discovery.count { |_, v| v[:loaded] }
end

#phase_listObject



55
56
57
# File 'lib/legion/gaia/registry.rb', line 55

def phase_list
  @phase_handlers.keys
end

#rediscoverObject



25
26
27
28
29
30
31
32
33
# File 'lib/legion/gaia/registry.rb', line 25

def rediscover
  @runner_instances = {}
  @phase_handlers = {}
  @discovery = {}
  @discovered = false
  discover

  { rediscovered: true, wired_phases: wired_count, phase_list: phase_list }
end

#tick_hostObject



39
40
41
# File 'lib/legion/gaia/registry.rb', line 39

def tick_host
  @runner_instances[:Tick_Orchestrator]
end

#total_countObject



47
48
49
# File 'lib/legion/gaia/registry.rb', line 47

def total_count
  @discovery.size
end

#wired_countObject



51
52
53
# File 'lib/legion/gaia/registry.rb', line 51

def wired_count
  @phase_handlers.size
end