Exception: Synthra::Errors::SimulatedConnectionDrop

Inherits:
SimulatedBehaviorError show all
Defined in:
lib/synthra/errors.rb

Overview

Simulated connection drop

Raised by the @close_connection behavior to simulate the connection being closed unexpectedly. Useful for testing reconnection logic.

Examples:

DSL usage

# Stream:
#   @close_connection 5%  <- 5% chance of SimulatedConnectionDrop
#   data: text

Constant Summary collapse

ERROR_CODE =
"SIMULATED_CONNECTION_DROP"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(probability: nil) ⇒ SimulatedConnectionDrop

Create a new SimulatedConnectionDrop

Parameters:

  • probability (Integer, nil) (defaults to: nil)

    the probability percentage if configured



1060
1061
1062
1063
1064
1065
# File 'lib/synthra/errors.rb', line 1060

def initialize(probability: nil)
  @probability = probability
  message = "Simulated connection drop"
  message += " (#{probability}% probability)" if probability
  super(message)
end

Instance Attribute Details

#probabilityInteger? (readonly)

Returns the configured probability percentage.

Returns:

  • (Integer, nil)

    the configured probability percentage



1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
# File 'lib/synthra/errors.rb', line 1050

class SimulatedConnectionDrop < SimulatedBehaviorError
  ERROR_CODE = "SIMULATED_CONNECTION_DROP"
  attr_reader :probability


  # Create a new SimulatedConnectionDrop
  #
  # @param probability [Integer, nil] the probability percentage if configured
  #

  def initialize(probability: nil)
    @probability = probability
    message = "Simulated connection drop"
    message += " (#{probability}% probability)" if probability
    super(message)
  end
end