Class: Google::Cloud::Debugger::Transmitter
- Inherits:
-
Object
- Object
- Google::Cloud::Debugger::Transmitter
- Defined in:
- lib/google/cloud/debugger/transmitter.rb
Overview
Transmitter
Responsible for submit evaluated breakpoints back to Stackdriver Debugger service asynchronously. It maintains a thread pool.
The transmitter is controlled by the debugger agent it belongs to. Debugger agent submits evaluated breakpoint asynchronously, and the transmitter submits the breakpoints to Stackdriver Debugger service.
Instance Attribute Summary collapse
-
#agent ⇒ Google::Cloud::Debugger::Agent
The debugger agent this transmiter belongs to.
-
#max_queue ⇒ Object
(also: #max_queue_size)
Maximum backlog size for this transmitter's queue.
-
#threads ⇒ Object
Maximum threads used in the thread pool.
Instance Method Summary collapse
-
#on_error {|callback| ... } ⇒ Object
Register to be notified of errors when raised.
-
#start ⇒ Transmitter
Starts the transmitter and its thread pool.
-
#started? ⇒ boolean
Whether the transmitter has been started.
-
#stop(timeout = nil) ⇒ Transmitter
Stops the transmitter and its thread pool.
-
#stopped? ⇒ boolean
Whether the transmitter has been stopped.
-
#submit(breakpoint) ⇒ Object
Enqueue an evaluated breakpoint to be submitted by the transmitter.
Instance Attribute Details
#agent ⇒ Google::Cloud::Debugger::Agent
The debugger agent this transmiter belongs to
60 61 62 |
# File 'lib/google/cloud/debugger/transmitter.rb', line 60 def agent @agent end |
#max_queue ⇒ Object Also known as: max_queue_size
Maximum backlog size for this transmitter's queue
64 65 66 |
# File 'lib/google/cloud/debugger/transmitter.rb', line 64 def max_queue @max_queue end |
#threads ⇒ Object
Maximum threads used in the thread pool
70 71 72 |
# File 'lib/google/cloud/debugger/transmitter.rb', line 70 def threads @threads end |
Instance Method Details
#on_error {|callback| ... } ⇒ Object
Register to be notified of errors when raised.
If an unhandled error has occurred the transmitter will attempt to recover from the error and resume submitting breakpoints.
Multiple error handlers can be added.
158 159 160 |
# File 'lib/google/cloud/debugger/transmitter.rb', line 158 def on_error &block @error_callbacks << block end |
#start ⇒ Transmitter
Starts the transmitter and its thread pool.
110 111 112 113 |
# File 'lib/google/cloud/debugger/transmitter.rb', line 110 def start # no-op self end |
#started? ⇒ boolean
Whether the transmitter has been started.
134 135 136 |
# File 'lib/google/cloud/debugger/transmitter.rb', line 134 def started? @thread_pool&.running? end |
#stop(timeout = nil) ⇒ Transmitter
Stops the transmitter and its thread pool. Once stopped, cannot be started again.
120 121 122 123 124 125 126 127 |
# File 'lib/google/cloud/debugger/transmitter.rb', line 120 def stop timeout = nil if @thread_pool @thread_pool.shutdown @thread_pool.wait_for_termination timeout end self end |
#stopped? ⇒ boolean
Whether the transmitter has been stopped.
143 144 145 |
# File 'lib/google/cloud/debugger/transmitter.rb', line 143 def stopped? !started? end |
#submit(breakpoint) ⇒ Object
Enqueue an evaluated breakpoint to be submitted by the transmitter.
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/google/cloud/debugger/transmitter.rb', line 95 def submit breakpoint Concurrent::Promises.future_on @thread_pool, breakpoint do |bp| submit_sync bp end rescue Concurrent::RejectedExecutionError => e raise TransmitterError.new( "Error asynchronously submitting breakpoint: #{e.}", breakpoint ) end |