Module: Julewire::Core::RuntimeRegistry
- Defined in:
- lib/julewire/core/runtime_registry.rb
Class Method Summary collapse
- .fetch(name, current: RuntimeLocator.current) ⇒ Object
- .prepare_before_fork(primary:, timeout:) ⇒ Object
- .reset(primary:) ⇒ Object
- .reset_after_fork(primary:) ⇒ Object
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 |
.prepare_before_fork(primary:, timeout:) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/julewire/core/runtime_registry.rb', line 51 def prepare_before_fork(primary:, timeout:) Validation.validate_timeout!(timeout, name: :timeout) runtimes = [primary] + @runtimes.get.values deadline = Scheduling::Deadline.for(timeout) begin runtimes.each do |runtime| runtime.before_fork_runtime!(timeout: Scheduling::Deadline.remaining(deadline)) end Integration::BeforeForkHooks.run rescue StandardError runtimes.reverse_each(&:cancel_before_fork_runtime!) raise end 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 |