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, :reset_peer, :delay, :timeout, :invalid_data, :bandwidth, :limit_data)

  • proxy (Nonnative::ConfigurationProxy)

    proxy configuration (host/port/options)

Returns:



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