Class: Nonnative::DelaySocketPair
- Inherits:
-
SocketPair
- Object
- SocketPair
- Nonnative::DelaySocketPair
- Defined in:
- lib/nonnative/delay_socket_pair.rb
Overview
Socket-pair variant used by the fault-injection proxy to simulate slow or stalled connections.
When active, reads from the socket are delayed by a configured duration before being forwarded.
The delay duration is controlled by proxy.options[:delay] and defaults to 2 seconds.
This behavior is enabled by calling FaultInjectionProxy#delay.
Instance Method Summary collapse
-
#read(socket) ⇒ String
Reads from the socket after sleeping for the configured delay duration.
Methods inherited from SocketPair
Constructor Details
This class inherits a constructor from Nonnative::SocketPair
Instance Method Details
#read(socket) ⇒ String
Reads from the socket after sleeping for the configured delay duration.
20 21 22 23 24 25 26 27 |
# File 'lib/nonnative/delay_socket_pair.rb', line 20 def read(socket) Nonnative.logger.info "delaying socket '#{socket.inspect}' for 'delay' pair" duration = proxy.[:delay] || 2 sleep duration super end |