Class: WebhookProcessorWorker
- Inherits:
-
Object
- Object
- WebhookProcessorWorker
- Includes:
- Sidekiq::Worker
- Defined in:
- app/workers/webhook_processor_worker.rb
Overview
Worker to process incoming webhooks from the webhook_logs table.
Follows the "ingest then process" pattern for reliable webhook handling.
This worker:
- Picks up a WebhookLog entry by ID
- Delegates to the appropriate processor based on provider/category
- Updates the log state (processed, retry, or exception)
The worker can be triggered:
- Immediately after a webhook is received
- By a scheduled job processing pending logs
- Manually for reprocessing
Instance Method Summary collapse
Instance Method Details
#perform(webhook_log_id) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/workers/webhook_processor_worker.rb', line 24 def perform(webhook_log_id) webhook_log = WebhookLog.find_by(id: webhook_log_id) unless webhook_log Rails.logger.warn "[WebhookProcessorWorker] WebhookLog #{webhook_log_id} not found" return end Rails.logger.info "[WebhookProcessorWorker] Processing WebhookLog #{webhook_log_id} (#{webhook_log.provider}/#{webhook_log.category})" # The WebhookLog#process! method handles state transitions and error handling webhook_log.process! Rails.logger.info "[WebhookProcessorWorker] WebhookLog #{webhook_log_id} now in state: #{webhook_log.state}" end |