Class: Nonnative::SocketPairFactory

Inherits:
Object
  • Object
show all
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:

Class Method Summary collapse

Class Method Details

.create(kind, proxy) ⇒ Nonnative::SocketPair

Creates a socket-pair instance for the given proxy state.

Parameters:

  • kind (Symbol)

    proxy state (e.g. :none, :close_all, :delay, :invalid_data)

  • proxy (Nonnative::ConfigurationProxy)

    proxy configuration (host/port/options)

Returns:



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