Class: Nonnative::SocketPairFactory
- Inherits:
-
Object
- Object
- Nonnative::SocketPairFactory
- Defined in:
- lib/nonnative/socket_pair_factory.rb
Overview
Factory for creating socket-pair implementations used by FaultInjectionProxy.
A socket-pair is responsible for wiring a local accepted socket to a remote upstream socket, optionally injecting failures (close connections, add delays, corrupt data, etc).
Proxy states are mapped as follows:
:none(or any unknown value) -> SocketPair (pass-through):close_all-> CloseAllSocketPair:reset_peer-> ResetPeerSocketPair:delay-> DelaySocketPair:timeout-> TimeoutSocketPair:invalid_data-> InvalidDataSocketPair:bandwidth-> BandwidthSocketPair:limit_data-> LimitDataSocketPair
Class Method Summary collapse
-
.create(kind, proxy) ⇒ Nonnative::SocketPair
Creates a socket-pair instance for the given proxy state.
Class Method Details
.create(kind, proxy) ⇒ Nonnative::SocketPair
Creates a socket-pair instance for the given proxy state.
47 48 49 50 51 |
# File 'lib/nonnative/socket_pair_factory.rb', line 47 def create(kind, proxy) pair = PAIR_BY_STATE.fetch(kind, SocketPair) pair.new(proxy) end |