Class: EventMachine::ProxyServer::Backend

Inherits:
Connection
  • Object
show all
Defined in:
lib/em-proxy/backend.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(debug = false) ⇒ Backend

Returns a new instance of Backend.



6
7
8
9
# File 'lib/em-proxy/backend.rb', line 6

def initialize(debug = false)
  @debug = debug
  @connected = EM::DefaultDeferrable.new
end

Instance Attribute Details

#debug=(value) ⇒ Object

Sets the attribute debug

Parameters:

  • value

    the value to set the attribute debug to.



4
5
6
# File 'lib/em-proxy/backend.rb', line 4

def debug=(value)
  @debug = value
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/em-proxy/backend.rb', line 4

def name
  @name
end

#plexerObject

Returns the value of attribute plexer.



4
5
6
# File 'lib/em-proxy/backend.rb', line 4

def plexer
  @plexer
end

Instance Method Details

#connection_completedObject



11
12
13
14
15
# File 'lib/em-proxy/backend.rb', line 11

def connection_completed
  debug [@name, :conn_complete]
  @plexer.connected(@name)
  @connected.succeed
end

#receive_data(data) ⇒ Object



17
18
19
20
# File 'lib/em-proxy/backend.rb', line 17

def receive_data(data)
  debug [@name, data]
  @plexer.relay_from_backend(@name, data)
end

#send(data) ⇒ Object

Buffer data until the connection to the backend server is established and is ready for use



24
25
26
# File 'lib/em-proxy/backend.rb', line 24

def send(data)
  @connected.callback { send_data data }
end

#unbind(reason = nil) ⇒ Object

Notify upstream plexer that the backend server is done processing the request



30
31
32
33
# File 'lib/em-proxy/backend.rb', line 30

def unbind(reason = nil)
  debug [@name, :unbind, reason]
  @plexer.unbind_backend(@name)
end