Module: Julewire::Core::RuntimeRegistry

Defined in:
lib/julewire/core/runtime_registry.rb

Class Method Summary collapse

Class Method Details

.fetch(name, current: RuntimeLocator.current) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/julewire/core/runtime_registry.rb', line 15

def fetch(name, current: RuntimeLocator.current)
  name = Core.normalize_name(name, name: "runtime name")
  return current if name == DEFAULT_NAME

  unless current.is_a?(Runtime)
    raise Error, "named Julewire runtimes are not available from the current runtime"
  end

  @runtimes.update do |runtimes|
    if runtimes.key?(name)
      runtimes
    else
      runtimes.merge(name => Runtime.new)
    end
  end.fetch(name)
end

.reset(primary:) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/julewire/core/runtime_registry.rb', line 32

def reset(primary:)
  runtimes = @runtimes.get_and_set(EMPTY_RUNTIMES).values

  primary.reset!
  runtimes.each(&:reset!)
  nil
end

.reset_after_fork(primary:) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/julewire/core/runtime_registry.rb', line 40

def reset_after_fork(primary:)
  runtimes = [primary] + @runtimes.get.values

  ContextStore.reset_current!
  Scheduling::SharedScheduler.after_fork!
  Diagnostics::ProcessIntegrationHealth.reset!
  Diagnostics::InvalidSeverityReporter.reset!
  runtimes.each(&:reset_after_fork_runtime!)
  Integration::ForkHooks.run
end