Class: Appsignal::Pipe
- Inherits:
-
Object
- Object
- Appsignal::Pipe
- Defined in:
- lib/appsignal/pipe.rb
Instance Attribute Summary collapse
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Pipe
constructor
A new instance of Pipe.
- #listening? ⇒ Boolean
- #stop_listening! ⇒ Object
- #write(transaction) ⇒ Object
Constructor Details
#initialize ⇒ Pipe
Returns a new instance of Pipe.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/appsignal/pipe.rb', line 5 def initialize Appsignal.logger.debug "Initializing pipe in #{$$}" @reader, @writer = IO.pipe @listener = Thread.new do loop do Appsignal.agent.enqueue(Marshal::load(@reader)) end end @listening = true end |
Instance Attribute Details
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
3 4 5 |
# File 'lib/appsignal/pipe.rb', line 3 def listener @listener end |
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
3 4 5 |
# File 'lib/appsignal/pipe.rb', line 3 def reader @reader end |
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
3 4 5 |
# File 'lib/appsignal/pipe.rb', line 3 def writer @writer end |
Class Method Details
.current ⇒ Object
38 39 40 |
# File 'lib/appsignal/pipe.rb', line 38 def current Thread.current[:appsignal_pipe] end |
Instance Method Details
#listening? ⇒ Boolean
29 30 31 |
# File 'lib/appsignal/pipe.rb', line 29 def listening? !! @listening end |
#stop_listening! ⇒ Object
23 24 25 26 27 |
# File 'lib/appsignal/pipe.rb', line 23 def stop_listening! Thread.kill(@listener) @reader.close unless @reader.closed? @listening = false end |