Class: ScheduleWorkers::AutoExtendAddOnMainWorker

Inherits:
ApplicationWorker show all
Defined in:
app/workers/schedule_workers/auto_extend_add_on_main_worker.rb

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Method Details

#performvoid

This method returns an undefined value.

Main entry point for the worker. Dispatches restaurant processing to sub-workers for parallel execution.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/workers/schedule_workers/auto_extend_add_on_main_worker.rb', line 20

def perform
  restaurant_ids = []

  Restaurant.with_auto_extend_add_ons.find_each(batch_size: 10) do |restaurant|
    restaurant_ids << restaurant.id
    # Use perform_in with random delay (0-5 minutes) to spread the load
    delay_seconds = rand(0..300)
    AutoExtendAddOnSubWorker.perform_in(delay_seconds, restaurant.id)
  end

  BUSINESS_LOGGER.info(
    "#{self.class}: Dispatched #{restaurant_ids.size} restaurants for add-on extension processing",
    restaurant_ids: restaurant_ids,
  )
end