Class: LogStash::Inputs::Tcp::DecoderImpl

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/inputs/tcp/decoder_impl.rb

Instance Method Summary collapse

Constructor Details

#initialize(codec, tcp) ⇒ DecoderImpl

Returns a new instance of DecoderImpl.



8
9
10
11
12
# File 'lib/logstash/inputs/tcp/decoder_impl.rb', line 8

def initialize(codec, tcp)
  @tcp = tcp
  @codec = codec
  @first_read = true
end

Instance Method Details

#copyObject



26
27
28
# File 'lib/logstash/inputs/tcp/decoder_impl.rb', line 26

def copy
  self.class.new(@codec.clone, @tcp)
end

#decode(channel_addr, data) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/logstash/inputs/tcp/decoder_impl.rb', line 14

def decode(channel_addr, data)
  bytes = Java::byte[data.readableBytes].new
  data.getBytes(0, bytes)
  data.release
  tbuf = String.from_java_bytes bytes, "ASCII-8BIT"
  if @first_read
    tbuf = init_first_read(channel_addr, tbuf)
  end
  @tcp.decode_buffer(@ip_address, @address, @port, @codec,
                     @proxy_address, @proxy_port, tbuf, nil)
end

#flushObject



30
31
32
# File 'lib/logstash/inputs/tcp/decoder_impl.rb', line 30

def flush
  @tcp.flush_codec(@codec, @ip_address, @address, @port, nil)
end