Module: FiberAudit::Runtime::Boot
- Defined in:
- lib/fiber_audit/runtime/boot.rb
Class Method Summary collapse
- .activate_from_environment!(environment: ENV, clock: Clock.new, session_id_source: SecureRandom.method(:uuid), pid_source: Process.method(:pid), writer_factory: JSONL::Writer.method(:open), random: Sampler::RANDOM_SOURCE) ⇒ Object
- .activated? ⇒ Boolean
- .current ⇒ Object
- .shutdown(exception: nil) ⇒ Object
Class Method Details
.activate_from_environment!(environment: ENV, clock: Clock.new, session_id_source: SecureRandom.method(:uuid), pid_source: Process.method(:pid), writer_factory: JSONL::Writer.method(:open), random: Sampler::RANDOM_SOURCE) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fiber_audit/runtime/boot.rb', line 11 def activate_from_environment!( environment: ENV, clock: Clock.new, session_id_source: SecureRandom.method(:uuid), pid_source: Process.method(:pid), writer_factory: JSONL::Writer.method(:open), random: Sampler::RANDOM_SOURCE ) return current if activated_for_current_process? mode = Environment.failure_mode(environment) return unless Environment.activated?(environment) settings = Environment.load(environment) watchdog_policy = if environment.key?(Environment::WATCHDOG_SETTINGS_KEY) Environment.load_watchdog_policy(environment) end @lifecycle = Lifecycle.start( settings: settings, watchdog_policy: watchdog_policy, probes_enabled: Environment.probes_enabled?(environment), clock: clock, session_id_source: session_id_source, pid_source: pid_source, writer_factory: writer_factory, random: random ) @pid_source = pid_source @activation_pid = pid_source.call install_shutdown_hook! @lifecycle rescue StandardError raise if defined?(mode) && mode == :closed nil end |
.activated? ⇒ Boolean
56 57 58 |
# File 'lib/fiber_audit/runtime/boot.rb', line 56 def activated? !current.nil? end |
.current ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/fiber_audit/runtime/boot.rb', line 48 def current return unless @lifecycle @lifecycle.ensure_current_process! @activation_pid = @pid_source.call @lifecycle end |
.shutdown(exception: nil) ⇒ Object
60 61 62 |
# File 'lib/fiber_audit/runtime/boot.rb', line 60 def shutdown(exception: nil) current&.shutdown(exception: exception) end |