Class: Hoss::Transport::Connection::ProxyPipe::Write Private
- Inherits:
-
Object
- Object
- Hoss::Transport::Connection::ProxyPipe::Write
- Includes:
- Logging
- Defined in:
- lib/hoss/transport/connection/proxy_pipe.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary
Constants included from Logging
Logging::LEVELS, Logging::PREFIX
Instance Attribute Summary collapse
- #io ⇒ Object readonly private
Class Method Summary collapse
- .finalize(io) ⇒ Object private
Instance Method Summary collapse
- #bytes_sent ⇒ Object private
- #close(reason = nil) ⇒ Object private
- #closed? ⇒ Boolean private
- #enable_compression! ⇒ Object private
-
#initialize(io, compress: true) ⇒ Write
constructor
private
A new instance of Write.
- #write(str) ⇒ Object private
Methods included from Logging
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(io, compress: true) ⇒ Write
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Write.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/hoss/transport/connection/proxy_pipe.rb', line 43 def initialize(io, compress: true) @io = io @compress = compress @bytes_sent = Concurrent::AtomicFixnum.new(0) @config = Hoss.agent&.config # this is silly, fix Logging return unless compress enable_compression! ObjectSpace.define_finalizer(self, self.class.finalize(@io)) end |
Instance Attribute Details
#io ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 |
# File 'lib/hoss/transport/connection/proxy_pipe.rb', line 58 def io @io end |
Class Method Details
.finalize(io) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 |
# File 'lib/hoss/transport/connection/proxy_pipe.rb', line 54 def self.finalize(io) proc { io.close } end |
Instance Method Details
#bytes_sent ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
82 83 84 |
# File 'lib/hoss/transport/connection/proxy_pipe.rb', line 82 def bytes_sent @bytes_sent.value end |
#close(reason = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 68 |
# File 'lib/hoss/transport/connection/proxy_pipe.rb', line 65 def close(reason = nil) debug("Closing writer with reason #{reason}") io.close end |
#closed? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 |
# File 'lib/hoss/transport/connection/proxy_pipe.rb', line 70 def closed? io.closed? end |
#enable_compression! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 |
# File 'lib/hoss/transport/connection/proxy_pipe.rb', line 60 def enable_compression! io.binmode @io = Zlib::GzipWriter.new(io) end |
#write(str) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 77 78 79 80 |
# File 'lib/hoss/transport/connection/proxy_pipe.rb', line 74 def write(str) io.puts(str).tap do @bytes_sent.update do |curr| @compress ? io.tell : curr + str.bytesize end end end |