Class: Rapns::Daemon::Store::ActiveRecord
- Inherits:
-
Object
- Object
- Rapns::Daemon::Store::ActiveRecord
show all
- Includes:
- Reconnectable
- Defined in:
- lib/rapns/daemon/store/active_record.rb,
lib/rapns/daemon/store/active_record/reconnectable.rb
Defined Under Namespace
Modules: Reconnectable
Constant Summary
Reconnectable::ADAPTER_ERRORS
Instance Method Summary
collapse
#check_database_is_connected, #database_connection_lost, #reconnect_database, #sleep_to_avoid_thrashing, #with_database_reconnect_and_retry
Instance Method Details
#after_daemonize ⇒ Object
68
69
70
|
# File 'lib/rapns/daemon/store/active_record.rb', line 68
def after_daemonize
reconnect_database
end
|
#create_apns_feedback(failed_at, device_token, app) ⇒ Object
48
49
50
51
52
53
|
# File 'lib/rapns/daemon/store/active_record.rb', line 48
def create_apns_feedback(failed_at, device_token, app)
with_database_reconnect_and_retry do
Rapns::Apns::Feedback.create!(:failed_at => failed_at,
:device_token => device_token, :app => app)
end
end
|
#create_gcm_notification(attrs, data, registration_ids, deliver_after, app) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/rapns/daemon/store/active_record.rb', line 55
def create_gcm_notification(attrs, data, registration_ids, deliver_after, app)
with_database_reconnect_and_retry do
notification = Rapns::Gcm::Notification.new
notification.assign_attributes(attrs)
notification.data = data
notification.registration_ids = registration_ids
notification.deliver_after = deliver_after
notification.app = app
notification.save!
notification
end
end
|
#deliverable_notifications(apps) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/rapns/daemon/store/active_record.rb', line 11
def deliverable_notifications(apps)
with_database_reconnect_and_retry do
batch_size = Rapns.config.batch_size
relation = Rapns::Notification.ready_for_delivery.for_apps(apps)
relation = relation.limit(batch_size) unless Rapns.config.push
relation.all
end
end
|
#mark_delivered(notification) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/rapns/daemon/store/active_record.rb', line 28
def mark_delivered(notification)
with_database_reconnect_and_retry do
notification.delivered = true
notification.delivered_at = Time.now
notification.save!(:validate => false)
end
end
|
#mark_failed(notification, code, description) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/rapns/daemon/store/active_record.rb', line 36
def mark_failed(notification, code, description)
with_database_reconnect_and_retry do
notification.delivered = false
notification.delivered_at = nil
notification.failed = true
notification.failed_at = Time.now
notification.error_code = code
notification.error_description = description
notification.save!(:validate => false)
end
end
|
#retry_after(notification, deliver_after) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/rapns/daemon/store/active_record.rb', line 20
def retry_after(notification, deliver_after)
with_database_reconnect_and_retry do
notification.retries += 1
notification.deliver_after = deliver_after
notification.save!(:validate => false)
end
end
|