Class: Admin::EventDeliveriesController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/generators/open_loam/install/templates/admin/event_deliveries_controller.rb

Overview

Durable event deliveries (OpenLoam::EventDelivery) — the dead-letter view. Manager-only. Lists deliveries parked as dead (handler removed, or retries exhausted) and lets an operator requeue one after fixing the handler. Pending deliveries drain on their own; a small sample is shown for visibility.

Constant Summary

Constants included from Pagination

Pagination::PER_PAGE

Instance Method Summary collapse

Methods inherited from BaseController

skip_authorization!

Methods included from Pagination

#paginate

Instance Method Details

#index ⇒ Object



9
10
11
12
# File 'lib/generators/open_loam/install/templates/admin/event_deliveries_controller.rb', line 9

def index
  @dead = OpenLoam::EventDelivery.dead.order(updated_at: :desc).limit(200)
  @pending = OpenLoam::EventDelivery.pending.order(Arel.sql("next_attempt_at IS NULL DESC, next_attempt_at ASC")).limit(50)
end

#redeliver ⇒ Object

Re-arm one delivery: back to pending with a clean slate, and nudge a job. The sweep would eventually pick it up anyway; this is the "try now" button.



16
17
18
19
20
21
# File 'lib/generators/open_loam/install/templates/admin/event_deliveries_controller.rb', line 16

def redeliver
  delivery = OpenLoam::EventDelivery.find(params[:id])
  delivery.update!(status: "pending", attempts: 0, next_attempt_at: nil, last_error: nil)
  OpenLoam::EventDeliveryJob.perform_later(delivery.tenant_id, delivery.id)
  redirect_to admin_event_deliveries_path, notice: "Delivery requeued."
end