Class: LittleGhost::Runtime::Hook
- Inherits:
-
Object
- Object
- LittleGhost::Runtime::Hook
- Defined in:
- lib/little_ghost/runtime/hook.rb
Overview
Hooks let applications prepare runs, select session history, transform interruptions, and map errors to caller-safe messages.
Hooks are instantiated once per Runtime in configuration order. Override only the methods needed and return the supplied value when leaving it unchanged.
class TenantHook < LittleGhost::Runtime::Hook
def prepare_run(run)
run.register(TenantConnection.new(run.invocation.actor_id))
run
end
end
Instance Method Summary collapse
-
#error_message(_error, _run) ⇒ Object
Returns a caller-safe error message, or nil to defer to later hooks and the runtime default.
-
#prepare_interruption(_run, payload) ⇒ Object
Transforms an interruption payload before it reaches the agent.
-
#prepare_run(run) ⇒ Object
Prepares a newly built Run.
-
#session_history(_run, stored:, fallback:) ⇒ Object
Returns the history to use for this run, or nil to defer to later hooks and the session default.
Instance Method Details
#error_message(_error, _run) ⇒ Object
Returns a caller-safe error message, or nil to defer to later hooks and the runtime default. Avoid exposing secrets or internal exception text.
33 |
# File 'lib/little_ghost/runtime/hook.rb', line 33 def (_error, _run) = nil |
#prepare_interruption(_run, payload) ⇒ Object
Transforms an interruption payload before it reaches the agent.
24 |
# File 'lib/little_ghost/runtime/hook.rb', line 24 def prepare_interruption(_run, payload) = payload |
#prepare_run(run) ⇒ Object
Prepares a newly built Run. Resources registered on the run share its lifecycle and close in reverse order.
21 |
# File 'lib/little_ghost/runtime/hook.rb', line 21 def prepare_run(run) = run |
#session_history(_run, stored:, fallback:) ⇒ Object
Returns the history to use for this run, or nil to defer to later hooks
and the session default. stored is empty when the session is new;
fallback contains messages supplied by the invocation.
29 |
# File 'lib/little_ghost/runtime/hook.rb', line 29 def session_history(_run, stored:, fallback:) = nil |