Class: Legion::Gaia::Registry

Inherits:
Object
  • Object
show all
Includes:
Logging::Helper, Singleton
Defined in:
lib/legion/gaia/registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry.



14
15
16
# File 'lib/legion/gaia/registry.rb', line 14

def initialize
  reset!
end

Instance Attribute Details

#discoveryObject (readonly)

Returns the value of attribute discovery.



12
13
14
# File 'lib/legion/gaia/registry.rb', line 12

def discovery
  @discovery
end

#phase_handlersObject (readonly)

Returns the value of attribute phase_handlers.



12
13
14
# File 'lib/legion/gaia/registry.rb', line 12

def phase_handlers
  @phase_handlers
end

#runner_instancesObject (readonly)

Returns the value of attribute runner_instances.



12
13
14
# File 'lib/legion/gaia/registry.rb', line 12

def runner_instances
  @runner_instances
end

Instance Method Details

#discoverObject



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

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



45
46
47
# File 'lib/legion/gaia/registry.rb', line 45

def ensure_wired
  discover unless @discovered
end

#loaded_countObject



53
54
55
# File 'lib/legion/gaia/registry.rb', line 53

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

#phase_listObject



65
66
67
# File 'lib/legion/gaia/registry.rb', line 65

def phase_list
  @phase_handlers.keys
end

#rediscoverObject



35
36
37
38
39
40
41
42
43
# File 'lib/legion/gaia/registry.rb', line 35

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

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

#reset!Object



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

def reset!
  @runner_instances = {}
  @phase_handlers = {}
  @discovery = {}
  @discovered = false
end

#tick_hostObject



49
50
51
# File 'lib/legion/gaia/registry.rb', line 49

def tick_host
  @runner_instances[:Tick_Orchestrator]
end

#total_countObject



57
58
59
# File 'lib/legion/gaia/registry.rb', line 57

def total_count
  @discovery.size
end

#wired_countObject



61
62
63
# File 'lib/legion/gaia/registry.rb', line 61

def wired_count
  @phase_handlers.size
end