Class: Rpush::Daemon::Pushy::Delivery

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MultiJsonHelper

#multi_json_dump, #multi_json_load

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.



9
10
11
12
13
14
# File 'lib/rpush/daemon/pushy/delivery.rb', line 9

def initialize(app, http, notification, batch)
  @http = http
  @notification = notification
  @batch = batch
  @pushy_uri = URI.parse("https://api.pushy.me/push?api_key=#{app.api_key}")
end

Instance Attribute Details

#batchObject (readonly)

Returns the value of attribute batch.



7
8
9
# File 'lib/rpush/daemon/pushy/delivery.rb', line 7

def batch
  @batch
end

#httpObject (readonly)

Returns the value of attribute http.



7
8
9
# File 'lib/rpush/daemon/pushy/delivery.rb', line 7

def http
  @http
end

#notificationObject (readonly)

Returns the value of attribute notification.



7
8
9
# File 'lib/rpush/daemon/pushy/delivery.rb', line 7

def notification
  @notification
end

#pushy_uriObject (readonly)

Returns the value of attribute pushy_uri.



7
8
9
# File 'lib/rpush/daemon/pushy/delivery.rb', line 7

def pushy_uri
  @pushy_uri
end

Instance Method Details

#performObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rpush/daemon/pushy/delivery.rb', line 16

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