Class: Vendors::MyMenu::ReservationInventorySyncWorker

Inherits:
ApplicationWorker
  • Object
show all
Defined in:
app/workers/vendors/my_menu/reservation_inventory_sync_worker.rb

Overview

Worker that triggers inventory sync for MyMenu when reservations are rejected due to inventory unavailability or when new reservations are created.

Since supplier inventory is synced on a scheduled basis, customers might encounter booking rejections when inventory data becomes stale. This worker delegates all sync logic to VendorsService::InventorySync::ReservationService, which handles different trigger types, cooldown periods, API rate limiting, and comprehensive logging/monitoring.

Supported trigger types:

  • :inv_mismatch - When inventory mismatches are detected, applies cooldown logic

  • :reservation_created - When new reservations are created, bypasses cooldown for immediate sync

The worker is kept minimal and only acts as a bridge between Sidekiq job processing and the business logic service. All error handling, logging, and APM instrumentation is handled by the service layer.

Instance Method Summary collapse

Instance Method Details

#perform(restaurant_id, date, trigger_type) ⇒ Object

Delegates inventory sync request to the reservation service

Parameters:

  • restaurant_id (Integer)

    ID of the restaurant to sync

  • date (String)

    Date to sync in 'YYYY-MM-DD' format

  • trigger_type (Symbol)

    Type of sync trigger (:inv_mismatch or :reservation_created)



28
29
30
31
# File 'app/workers/vendors/my_menu/reservation_inventory_sync_worker.rb', line 28

def perform(restaurant_id, date, trigger_type)
  service = VendorsService::InventorySync::ReservationService.new(:mymenu)
  service.sync_if_needed(restaurant_id: restaurant_id, date: date, trigger_type: trigger_type.to_sym)
end