Class: Proxi::SlowDown

Inherits:
Object
  • Object
show all
Defined in:
lib/proxi/listeners.rb

Overview

Wait before handing back data coming from the remote, this simulates a slow connection, and can be used to test timeouts.

Instance Method Summary collapse

Constructor Details

#initialize(wait_seconds: 5) ⇒ SlowDown

Returns a new instance of SlowDown.


42
43
44
# File 'lib/proxi/listeners.rb', line 42

def initialize(wait_seconds: 5)
  @wait_seconds = wait_seconds
end

Instance Method Details

#new_connection(connection) ⇒ Object


46
47
48
# File 'lib/proxi/listeners.rb', line 46

def new_connection(connection)
  connection.on(:data_out) { sleep @wait_seconds }
end