Module: Envoy::Client::Channel

Defined in:
lib/envoy/client/channel.rb

Instance Method Summary collapse

Instance Method Details

#connection_completedObject



14
15
16
17
18
19
# File 'lib/envoy/client/channel.rb', line 14

def connection_completed
  @client.log TRACE, "connected to upstream service for stream #{@id}"
  @tried_starting = nil
  send_data @buffer, true
  @buffer = nil
end

#initialize(id, client) ⇒ Object



8
9
10
11
12
# File 'lib/envoy/client/channel.rb', line 8

def initialize id, client
  @id, @client = id, client
  @buffer = ""
  super()
end

#receive_data(data) ⇒ Object



29
30
31
32
# File 'lib/envoy/client/channel.rb', line 29

def receive_data data
  @client.log TRACE, "#{data.length} bytes of data send on stream #{@id}"
  @client.send_object :stream, @id, data
end

#reconnectObject



34
35
36
37
# File 'lib/envoy/client/channel.rb', line 34

def reconnect
  @client.log TRACE, "reconnecting to upstream service for stream #{@id}"
  super @client.options[:local_host], @client.options[:local_port]
end

#send_data(data, force = false) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/envoy/client/channel.rb', line 21

def send_data data, force = false
  if !@buffer or force
    super data
  else
    @buffer << data
  end
end

#unbind(e) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/envoy/client/channel.rb', line 39

def unbind e
  if e == Errno::ECONNREFUSED
    @client.log ERROR, "couldn't connect to upstream service for stream #{@id}"
    @client.send_object :close, @id
  elsif e
    @client.log ERROR, e.inspect
    @client.send_object :close, @id
  else
    @client.log DEBUG, "upstream service closed stream #{@id}"
    @client.send_object :close, @id
  end
end