Class: Nonnative::FlakySocketPair
- Inherits:
-
SocketPair
- Object
- SocketPair
- Nonnative::FlakySocketPair
- Defined in:
- lib/nonnative/flaky_socket_pair.rb
Overview
Socket-pair variant used by the fault-injection proxy to simulate a flapping dependency.
When active, each new connection independently fails with probability
proxy.options[:probability] (closed immediately, like CloseAllSocketPair) and
otherwise forwards normally. Because the decision is made per connection rather than per state, a
client that retries/reconnects can observe some attempts fail and others succeed while this fault
state stays active, exercising retry/reconnect/circuit-breaker recovery rather than a fully down
dependency. A missing or non-positive probability behaves like pass-through; probability >= 1.0
fails every connection.
This behavior is enabled by calling Nonnative::FaultInjectionProxy#flaky.
Instance Method Summary collapse
-
#connect(local_socket) ⇒ void
Fails the connection with the configured probability, otherwise forwards it normally.
Methods inherited from SocketPair
Constructor Details
This class inherits a constructor from Nonnative::SocketPair
Instance Method Details
#connect(local_socket) ⇒ void
This method returns an undefined value.
Fails the connection with the configured probability, otherwise forwards it normally.
25 26 27 28 29 30 31 |
# File 'lib/nonnative/flaky_socket_pair.rb', line 25 def connect(local_socket) return super unless fail? Nonnative.logger.info "closing socket '#{local_socket.inspect}' for 'flaky' pair" local_socket.close end |