Class: ApplicationInsights::Channel::SynchronousQueue
- Defined in:
- lib/application_insights/channel/synchronous_queue.rb
Overview
A synchronous queue for use in conjunction with the SynchronousSender. The queue will call ApplicationInsights::Channel::SenderBase#send when it reaches QueueBase#max_queue_length, or when the consumer calls #flush.
Instance Attribute Summary
Attributes inherited from QueueBase
Instance Method Summary collapse
-
#flush ⇒ Object
Flushes the current queue by by calling QueueBase#sender‘s ApplicationInsights::Channel::SenderBase#send method.
-
#initialize(sender) ⇒ SynchronousQueue
constructor
Initializes a new instance of the class.
Methods inherited from QueueBase
Constructor Details
#initialize(sender) ⇒ SynchronousQueue
Initializes a new instance of the class.
19 20 21 |
# File 'lib/application_insights/channel/synchronous_queue.rb', line 19 def initialize(sender) super sender end |
Instance Method Details
#flush ⇒ Object
Flushes the current queue by by calling QueueBase#sender‘s ApplicationInsights::Channel::SenderBase#send method.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/application_insights/channel/synchronous_queue.rb', line 25 def flush local_sender = @sender return unless local_sender while true # get at most send_buffer_size items and send them data = [] while data.length < local_sender.send_buffer_size item = pop() break if not item data.push item end break if data.length == 0 local_sender.send(data) end end |