Class: Rpush::Daemon::Apns2::Delivery
- Defined in:
- lib/rpush/daemon/apns2/delivery.rb
Constant Summary collapse
- RETRYABLE_CODES =
[ 429, 500, 503 ]
- CLIENT_JOIN_TIMEOUT =
60
Instance Method Summary collapse
-
#initialize(app, http2_client, batch) ⇒ Delivery
constructor
A new instance of Delivery.
- #perform ⇒ Object
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
Constructor Details
#initialize(app, http2_client, batch) ⇒ Delivery
Returns a new instance of Delivery.
12 13 14 15 16 |
# File 'lib/rpush/daemon/apns2/delivery.rb', line 12 def initialize(app, http2_client, batch) @app = app @client = http2_client @batch = batch end |
Instance Method Details
#perform ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rpush/daemon/apns2/delivery.rb', line 18 def perform @batch.each_notification do |notification| prepare_async_post(notification) end # Send all preprocessed requests at once @client.join(timeout: CLIENT_JOIN_TIMEOUT) rescue NetHttp2::AsyncRequestTimeout => error mark_batch_retryable(Time.now + 10.seconds, error) @client.close raise rescue Errno::ECONNREFUSED, SocketError => error mark_batch_retryable(Time.now + 10.seconds, error) raise rescue StandardError => error mark_batch_failed(error) raise ensure @batch.all_processed end |