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
10
# File 'lib/em-proxy/backend.rb', line 6

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

Instance Attribute Details

#dataObject

Returns the value of attribute data.



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

def data
  @data
end

#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



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

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

#receive_data(data) ⇒ Object



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

def receive_data(data)
  debug [@name, data]
  @data.push 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



26
27
28
# File 'lib/em-proxy/backend.rb', line 26

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

#unbindObject

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



32
33
34
35
# File 'lib/em-proxy/backend.rb', line 32

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