Class: RetailerProbeWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/workers/retailer_probe_worker.rb

Overview

Worker to probe retailer product pages for availability and pricing.
Designed to be run daily via Sidekiq scheduler.

Uses two different strategies:

  • Single item: Realtime API (synchronous, immediate result)
  • Catalog/All: Batch API with webhooks (async, results via WebhookProcessorWorker)

Schedule in sidekiq.yml:

retailer_probes:
cron: "0 6 * * *" # 6 AM daily
class: RetailerProbeWorker
queue: low

Examples:

Run manually for a single item (uses realtime API)

RetailerProbeWorker.perform_async(catalog_item_id: 12345)

Run for a catalog (uses batch API with callbacks)

RetailerProbeWorker.perform_async(catalog_id: 18)

Run for all retailers (uses batch API with callbacks)

RetailerProbeWorker.perform_async

See Also:

Instance Method Summary collapse

Instance Method Details

#perform(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})

    Job arguments

Options Hash (options):

  • catalog_item_id (Integer)

    Probe a single CatalogItem (realtime API)

  • catalog_id (Integer)

    Probe a whole Catalog (batch API with callbacks); omitted probes all retailers



38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/workers/retailer_probe_worker.rb', line 38

def perform(options = {})
  if options[:catalog_item_id]
    # Single item: use realtime API for immediate feedback
    check_single_item(options[:catalog_item_id])
  elsif options[:catalog_id]
    # Catalog: use batch API with callbacks
    check_catalog_batch(options[:catalog_id])
  else
    # All retailers: use batch API with callbacks
    check_all_retailers_batch
  end
end