Class: Rpush::Daemon::Webpush::Delivery

Inherits:
Delivery
  • Object
show all
Defined in:
lib/rpush/daemon/webpush/delivery.rb

Constant Summary collapse

OK =
[ 200, 201, 202 ].freeze
TEMPORARY_FAILURES =
[ 429, 500, 502, 503, 504 ].freeze

Instance Method Summary collapse

Methods inherited from Delivery

#mark_batch_delivered, #mark_batch_failed, #mark_batch_retryable, #mark_delivered, #mark_failed, #mark_retryable, #mark_retryable_exponential

Methods included from Loggable

#log_debug, #log_error, #log_info, #log_warn

Methods included from Reflectable

#reflect

Constructor Details

#initialize(app, http, notification, batch) ⇒ Delivery

Returns a new instance of Delivery.



26
27
28
29
30
31
# File 'lib/rpush/daemon/webpush/delivery.rb', line 26

def initialize(app, http, notification, batch)
  @app = app
  @http = http
  @notification = notification
  @batch = batch
end

Instance Method Details

#performObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rpush/daemon/webpush/delivery.rb', line 33

def perform
  response = send_request
  process_response response
rescue SocketError, SystemCallError => error
  mark_retryable(@notification, Time.now + 10.seconds, error)
  raise
rescue StandardError => error
  mark_failed(error)
  raise
ensure
  @batch.notification_processed
end