Class: DeliveryManualReleaseDueNotificationHandler

Inherits:
ApplicationJob
  • Object
show all
Includes:
RailsEventStore::AsyncHandler
Defined in:
app/subscribers/delivery_manual_release_due_notification_handler.rb

Overview

Sends the "manual-release future delivery is past due" notification when the
scheduled release date arrives but the delivery is flagged for manual
release only.

WHY async via event: the delivery is captured by id at publish time and
re-queried at perform time, so a destroy between cron-publish and email-send
is a clean no-op instead of ActiveJob::DeserializationError
(AppSignal #4958). Replaces a direct InternalMailer.…deliver_later call
from Delivery.send_manual_release_due_notification.

Instance Method Summary collapse

Instance Method Details

#perform(event) ⇒ void

This method returns an undefined value.

Processes a persisted manual-release-due event: re-queries the delivery
and silently no-ops when it's gone.

Parameters:

  • event (RubyEventStore::Event)

    the persisted Events::DeliveryManualReleaseDue event

Raises:

  • (StandardError)

    if sending the notification fails



26
27
28
29
30
31
32
33
34
# File 'app/subscribers/delivery_manual_release_due_notification_handler.rb', line 26

def perform(event)
  delivery = Delivery.find_by(id: event.data[:delivery_id])
  return unless delivery

  DeliveryMailer.manual_release_delivery_due_notification(delivery).deliver_now
rescue StandardError => e
  ErrorReporting.error(e)
  raise
end