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

View Source

Enhanced error pattern learning specifically for recovery scenarios.

This module extends the existing ErrorPatternLearner with recovery-specific features like success rate tracking for different recovery strategies, integration with the recovery supervisor, and adaptive strategy selection.

Features

  • Recovery strategy success rate tracking
  • Context-aware pattern analysis
  • Integration with RecoverySupervisor
  • Adaptive strategy recommendation
  • Performance impact correlation

Usage

# Record a recovery attempt
EnhancedPatternLearner.record_recovery_attempt(
  error_signature,
  :circuit_break,
  :success,
  %{recovery_time_ms: 2500}
)

# Get recommended recovery strategy
strategy = EnhancedPatternLearner.recommend_recovery_strategy(
  error_signature,
  %{restart_count: 3, performance_impact: :high}
)

Summary

Functions

Returns a specification to start this module under a supervisor.

Export recovery learning data.

Get recovery patterns that correlate with performance issues.

Get learning statistics for recovery patterns.

Get success rates for all recovery strategies for a given error.

Get the recommended recovery strategy for an error.

Update adaptive thresholds based on system performance.

Types

recovery_context()

@type recovery_context() :: map()

recovery_outcome()

@type recovery_outcome() :: :success | :failure | :partial_success

recovery_pattern()

@type recovery_pattern() :: %{
  error_signature: String.t(),
  strategy: recovery_strategy(),
  success_rate: float(),
  avg_recovery_time_ms: float(),
  performance_impact: atom(),
  context_correlations: map(),
  last_updated: DateTime.t()
}

recovery_strategy()

@type recovery_strategy() :: atom()

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

export_recovery_data(format)

Export recovery learning data.

get_performance_impact_patterns()

Get recovery patterns that correlate with performance issues.

get_recovery_learning_stats()

Get learning statistics for recovery patterns.

get_strategy_success_rates(error_signature)

Get success rates for all recovery strategies for a given error.

handle_manager_info(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.

recommend_recovery_strategy(error_signature, context)

Get the recommended recovery strategy for an error.

record_recovery_attempt(error_signature, strategy, outcome, context)

Record a recovery attempt and its outcome.

start_link(init_opts \\ [])

update_adaptive_thresholds(performance_metrics)

Update adaptive thresholds based on system performance.