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 -
:delay-> DelaySocketPair -
:invalid_data-> InvalidDataSocketPair
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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nonnative/socket_pair_factory.rb', line 27 def create(kind, proxy) pair = case kind when :close_all CloseAllSocketPair when :delay DelaySocketPair when :invalid_data InvalidDataSocketPair else SocketPair end pair.new(proxy) end |