Class: RedisHA::Router::Upstream

Inherits:
EventMachine::Connection
  • Object
show all
Includes:
Logger
Defined in:
lib/redis_ha/router/upstream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(debug_on = false) ⇒ Upstream

Returns a new instance of Upstream.



8
9
10
11
# File 'lib/redis_ha/router/upstream.rb', line 8

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

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



6
7
8
# File 'lib/redis_ha/router/upstream.rb', line 6

def debug
  @debug
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/redis_ha/router/upstream.rb', line 6

def name
  @name
end

#plexerObject

Returns the value of attribute plexer.



6
7
8
# File 'lib/redis_ha/router/upstream.rb', line 6

def plexer
  @plexer
end

Instance Method Details

#connection_completedObject



13
14
15
16
17
# File 'lib/redis_ha/router/upstream.rb', line 13

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

#receive_data(data) ⇒ Object



19
20
21
22
# File 'lib/redis_ha/router/upstream.rb', line 19

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

#send(data) ⇒ Object



24
25
26
# File 'lib/redis_ha/router/upstream.rb', line 24

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

#ubindObject



28
29
30
31
# File 'lib/redis_ha/router/upstream.rb', line 28

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