class ElasticAPM::Transport::Connection::ProxyPipe::Write

@api private

Attributes

io[R]

Public Class Methods

new(io, compress: true) click to toggle source
# File lib/elastic_apm/transport/connection/proxy_pipe.rb, line 29
def initialize(io, compress: true)
  @io = io
  @compress = compress
  @bytes_sent = Concurrent::AtomicFixnum.new(0)
  @config = ElasticAPM.agent&.config # this is silly, fix Logging

  return unless compress
  enable_compression!
end

Public Instance Methods

bytes_sent() click to toggle source
# File lib/elastic_apm/transport/connection/proxy_pipe.rb, line 63
def bytes_sent
  @bytes_sent.value
end
close(reason = nil) click to toggle source
# File lib/elastic_apm/transport/connection/proxy_pipe.rb, line 46
def close(reason = nil)
  debug("Closing writer with reason #{reason}")
  io.close
end
closed?() click to toggle source
# File lib/elastic_apm/transport/connection/proxy_pipe.rb, line 51
def closed?
  io.closed?
end
enable_compression!() click to toggle source
# File lib/elastic_apm/transport/connection/proxy_pipe.rb, line 41
def enable_compression!
  io.binmode
  @io = Zlib::GzipWriter.new(io)
end
write(str) click to toggle source
# File lib/elastic_apm/transport/connection/proxy_pipe.rb, line 55
def write(str)
  io.puts(str).tap do
    @bytes_sent.update do |curr|
      @compress ? io.tell : curr + str.bytesize
    end
  end
end