Class: Maintenance::WebhookMaintenance

Inherits:
BaseService show all
Defined in:
app/services/maintenance/webhook_maintenance.rb

Overview

Cleans up stale WebhookLog entries that will never receive a callback.

Three operations, run daily:

  1. Times out pending entries older than 24h (pending → exception via timeout!)
  2. Fails processing entries stuck for >2h (processing → exception via fail!)
  3. Deletes terminal entries (exception/processed/archived) older than 90 days

The StaleTranscriptionRecoveryWorker handles AssemblyAI-specific recovery
(checking their API, retrying). This service is the blunt safety net that
sweeps up anything left behind by any provider.

Examples:

Manual invocation

Maintenance::WebhookMaintenance.new.process

Via ServiceRunner (scheduled)

ServiceRunner.perform_async('Maintenance::WebhookMaintenance')

Constant Summary collapse

PENDING_TIMEOUT =
24.hours
PROCESSING_TIMEOUT =
2.hours
DELETE_AGE =
90.days
BATCH_LIMIT =
500

Instance Method Summary collapse

Methods inherited from BaseService

#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #tagged_logger

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#processObject



26
27
28
29
30
31
32
33
34
35
# File 'app/services/maintenance/webhook_maintenance.rb', line 26

def process
  stats = {
    timed_out: timeout_stale_pending,
    unstuck: fail_stuck_processing,
    deleted: delete_old_terminal
  }

  log_info "Webhook maintenance complete — #{stats.inspect}"
  stats
end