Class: ActionNativePush::NotificationJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- ActionNativePush::NotificationJob
- Defined in:
- app/jobs/action_native_push/notification_job.rb
Class Method Summary collapse
-
.exponential_backoff_delay(executions) ⇒ Object
Exponential backoff starting from a minimum of 1 minute, capped at 60m as suggested by FCM: firebase.google.com/docs/cloud-messaging/scale-fcm#errors.
- .retry_options ⇒ Object
Instance Method Summary collapse
Class Method Details
.exponential_backoff_delay(executions) ⇒ Object
Exponential backoff starting from a minimum of 1 minute, capped at 60m as suggested by FCM: firebase.google.com/docs/cloud-messaging/scale-fcm#errors
| Executions | Delay (rounded minutes) | |————|————————-| | 1 | 1 | | 2 | 2 | | 3 | 4 | | 4 | 8 | | 5 | 16 | | 6 | 32 | | 7 | 60 (cap) |
31 32 33 34 35 36 37 38 |
# File 'app/jobs/action_native_push/notification_job.rb', line 31 def exponential_backoff_delay(executions) base_wait = 1.minute delay = base_wait * (2**(executions - 1)) jitter = 0.15 jitter_delay = rand * delay * jitter [ delay + jitter_delay, 60.minutes ].min end |
.retry_options ⇒ Object
15 16 17 |
# File 'app/jobs/action_native_push/notification_job.rb', line 15 def Rails.version >= "8.1" ? { report: report_job_retries } : {} end |
Instance Method Details
#perform(notification_class, notification_attributes, device) ⇒ Object
54 55 56 |
# File 'app/jobs/action_native_push/notification_job.rb', line 54 def perform(notification_class, notification_attributes, device) notification_class.constantize.new(**notification_attributes).deliver_to(device) end |