Module: Langfuse::ForkSafety Private

Defined in:
lib/langfuse/fork_safety.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Restores SDK-owned background state in a forked child process.

Defined Under Namespace

Modules: ProcessHook

Class Method Summary collapse

Class Method Details

.after_forkvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Reset every live registered resource in the child process.



32
33
34
35
36
37
# File 'lib/langfuse/fork_safety.rb', line 32

def after_fork
  reset_inherited_mutexes
  registry.each_key { |resource| reset_resource(resource) }
rescue StandardError => e
  Kernel.warn("Langfuse fork reset failed: #{e.class} - #{e.message}")
end

.register(resource) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Register an SDK resource that implements a private #reset_after_fork method.

Parameters:

  • resource (Object)

    Fork-sensitive SDK resource



24
25
26
27
# File 'lib/langfuse/fork_safety.rb', line 24

def register(resource)
  install!
  registry_mutex.synchronize { registry[resource] = true }
end