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 OxylabsResultWorker)

Examples:

Schedule in sidekiq.yml

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

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

Instance Method Summary collapse

Instance Method Details

#perform(options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/workers/retailer_probe_worker.rb', line 30

def perform(options = {})
  options = options.symbolize_keys

  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