Raxol.Core.ErrorRecovery.RecoveryWrapper (Raxol v2.0.1)

View Source

Wrapper module that adds recovery capabilities to any GenServer process.

This module wraps existing GenServers to provide enhanced error recovery features without requiring modifications to the original modules.

Features

  • Automatic context preservation before termination
  • State restoration after restart
  • Error pattern recording
  • Performance impact monitoring
  • Graceful shutdown handling

Usage

# Start a wrapped process
RecoveryWrapper.start_link(MyWorker, [
  worker_args: [arg1, arg2],
  context_key: :my_worker,
  recovery_supervisor: RecoverySupervisor
])

Summary

Functions

Returns a specification to start this module under a supervisor.

Get recovery statistics for the wrapped process.

Get the current state of the wrapped process.

Manually trigger a state snapshot.

Types

wrapper_opts()

@type wrapper_opts() :: [
  worker_args: term(),
  context_key: term(),
  recovery_supervisor: pid() | atom(),
  context_manager: pid() | atom(),
  dependency_graph: term(),
  snapshot_interval: pos_integer()
]

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_recovery_stats(wrapper_pid)

Get recovery statistics for the wrapped process.

get_wrapped_state(wrapper_pid)

Get the current state of the wrapped process.

snapshot_state(wrapper_pid)

Manually trigger a state snapshot.

start_link(wrapped_module, opts \\ [])