module LittleGhost::ExecutionState
ExecutionState carries request-scoped values across fibers and the worker threads LittleGhost creates. It keeps event and instrumentation context from leaking between concurrent runs.
Framework extensions may use #capture and #with to preserve event and instrumentation context. Captured hashes are immutable; values within them are not deep-copied.
Public Class Methods
Source
# File lib/little_ghost/execution_state.rb, line 17 def [](key) state[key] end
Reads key from the current execution state.
Source
# File lib/little_ghost/execution_state.rb, line 22 def []=(key, value) replace(state.merge(key => value)) end
Replaces key in the current fiber-local state.
Source
# File lib/little_ghost/execution_state.rb, line 34 def capture state end
Captures the current immutable state hash for propagation.
Source
# File lib/little_ghost/execution_state.rb, line 27 def delete(key) value = state[key] replace(state.except(key)) value end
Deletes key and returns its previous value.
Source
# File lib/little_ghost/execution_state.rb, line 39 def with(values) previous = state replace(previous.merge(values)) yield ensure replace(previous) end
Merges values while the block runs, then restores prior state.