Module: Datadog::Workers::Queue
Overview
Adds queue behavior to workers, with a buffer
to which items can be queued then dequeued.
Defined Under Namespace
Modules: PrependedMethods
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#buffer ⇒ Object
18
19
20
|
# File 'lib/ddtrace/workers/queue.rb', line 18
def buffer
@buffer ||= []
end
|
Class Method Details
.included(base) ⇒ Object
7
8
9
|
# File 'lib/ddtrace/workers/queue.rb', line 7
def self.included(base)
base.prepend(PrependedMethods)
end
|
Instance Method Details
#dequeue ⇒ Object
26
27
28
|
# File 'lib/ddtrace/workers/queue.rb', line 26
def dequeue
buffer.shift
end
|
#enqueue(*args) ⇒ Object
22
23
24
|
# File 'lib/ddtrace/workers/queue.rb', line 22
def enqueue(*args)
buffer.push(args)
end
|
#work_pending? ⇒ Boolean
Are there more items to be processed next?
31
32
33
|
# File 'lib/ddtrace/workers/queue.rb', line 31
def work_pending?
!buffer.empty?
end
|