Class: SqsPoller::Process::TaskFinalizer
- Inherits:
-
Object
- Object
- SqsPoller::Process::TaskFinalizer
- Defined in:
- lib/sqspoller/process/task_finalizer.rb
Constant Summary collapse
- DEFAULT_FINALIZE_TIMER_DELAY =
5.0
- MAX_SQS_DELETE_BATCH_SIZE =
10
- MAX_DELETE_RETRY =
5
Instance Method Summary collapse
- #buffer_size ⇒ Object
- #finalize(completed_task) ⇒ Object
-
#initialize(buffer_size) ⇒ TaskFinalizer
constructor
A new instance of TaskFinalizer.
Constructor Details
#initialize(buffer_size) ⇒ TaskFinalizer
Returns a new instance of TaskFinalizer.
21 22 23 24 25 26 |
# File 'lib/sqspoller/process/task_finalizer.rb', line 21 def initialize(buffer_size) @logger = SqsPoller::Logger.get_new_logger(self.class.name) @buffer_size = buffer_size @completed_tasks = SqsPoller::Common::RingBuffer.new(buffer_size * 2) schedule_timer end |
Instance Method Details
#buffer_size ⇒ Object
28 29 30 |
# File 'lib/sqspoller/process/task_finalizer.rb', line 28 def buffer_size @buffer_size end |
#finalize(completed_task) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/sqspoller/process/task_finalizer.rb', line 32 def finalize(completed_task) @completed_tasks.push completed_task if @completed_tasks.count >= @buffer_size @timer.reset finalize_tasks end end |