Class: ApplicationInsights::Channel::AsynchronousQueue
- Defined in:
- lib/application_insights/channel/asynchronous_queue.rb
Overview
An asynchronous queue for use in conjunction with the AsynchronousSender. The queue will notify the sender that it needs to pick up items when it reaches QueueBase#max_queue_length, or when the consumer calls #flush via the #flush_notification event.
Instance Attribute Summary collapse
-
#flush_notification ⇒ Event
readonly
The flush notification Event that the QueueBase#sender will use to get notified that a flush is needed.
Attributes inherited from QueueBase
Instance Method Summary collapse
-
#flush ⇒ Object
Flushes the current queue by notifying the QueueBase#sender via the #flush_notification event.
-
#initialize(sender) ⇒ AsynchronousQueue
constructor
Initializes a new instance of the class.
-
#push(item) ⇒ Object
Adds the passed in item object to the queue and notifies the QueueBase#sender to start an asynchronous send operation by calling ApplicationInsights::Channel::AsynchronousSender#start.
Methods inherited from QueueBase
Constructor Details
#initialize(sender) ⇒ AsynchronousQueue
Initializes a new instance of the class.
30 31 32 33 |
# File 'lib/application_insights/channel/asynchronous_queue.rb', line 30 def initialize(sender) @flush_notification = Event.new super sender end |
Instance Attribute Details
#flush_notification ⇒ Event (readonly)
The flush notification Event that the QueueBase#sender will use to get notified that a flush is needed.
38 39 40 |
# File 'lib/application_insights/channel/asynchronous_queue.rb', line 38 def flush_notification @flush_notification end |
Instance Method Details
#flush ⇒ Object
Flushes the current queue by notifying the QueueBase#sender via the #flush_notification event.
52 53 54 55 |
# File 'lib/application_insights/channel/asynchronous_queue.rb', line 52 def flush @flush_notification.set @sender.start if @sender end |
#push(item) ⇒ Object
Adds the passed in item object to the queue and notifies the QueueBase#sender to start an asynchronous send operation by calling ApplicationInsights::Channel::AsynchronousSender#start.
45 46 47 48 |
# File 'lib/application_insights/channel/asynchronous_queue.rb', line 45 def push(item) super item @sender.start if @sender end |