resque-aps 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.9.8 (2010-08-08)
2
+
3
+ * Fix a bug in the aps_read_error logging method.
4
+
1
5
  ## 0.9.7 (2010-07-26)
2
6
 
3
7
  * Add a rake task to get the lengths of the application queues.
data/README.markdown ADDED
@@ -0,0 +1,84 @@
1
+ resque-aps
2
+ ===============
3
+
4
+ Resque-Aps is an extension to [Resque](http://github.com/defunkt/resque)
5
+ that adds shortcuts to send notifications to Apple's Push System.
6
+
7
+ Installation and integration with callbacks
8
+ --------------------------------------
9
+
10
+ To install:
11
+
12
+ gem install resque-aps
13
+
14
+ You'll need to add this to your Rails rakefile to see the queue lengths:
15
+
16
+ require 'resque_aps/tasks'
17
+ task "resque:setup" => :environment
18
+
19
+ $ rake resque:aps:queue_lengths
20
+
21
+ I use this to monitor the system in nagios.
22
+
23
+ To extend the system create an initializer:
24
+
25
+ require 'resque_aps'
26
+
27
+ Resque.aps_gateway_host = AppConfig.apn_gateway_host
28
+ Resque.aps_gateway_port = AppConfig.apn_gateway_port
29
+ Resque.aps_feedback_host = AppConfig.apn_feedback_host
30
+ Resque.aps_feedback_port = AppConfig.apn_feedback_port
31
+
32
+ module ResqueAps
33
+ class Application
34
+ def after_aps_write(notification)
35
+ logger.info("Sent Notification [#{notification.application_name}] [#{notification.device_token}] [#{notification.payload}]") if logger
36
+ end
37
+
38
+ # It probably failed because there is something wrong with the device token
39
+ # do not requeue.
40
+ def failed_aps_write(notification, exception)
41
+ logger.error "failed_aps_write: #{notification.inspect} - #{exception}"
42
+ logger.error exception.backtrace.join("\n")
43
+ end
44
+
45
+ # Something is probably wrong with the certificate
46
+ def notify_aps_admin(exception)
47
+ # Notify once a minute
48
+ unless Rails.cache.read("push_certificate:notify_admin:#{name}")
49
+ logger.error("notification: #{exception.message}")
50
+ # Email error to someone
51
+ Rails.cache.write("push_certificate:notify_admin:#{name}", "true", :expires_in => 60)
52
+ end
53
+ rescue
54
+ logger.error("#{$!} (#{name}): #{$!.backtrace.join("\n")}")
55
+ end
56
+
57
+ def aps_nil_notification_retry?(sent_count, start_time)
58
+ # Live forever
59
+ sleep 1
60
+ true
61
+ # Or not
62
+ #false
63
+ end
64
+
65
+ def after_aps_read(feedback)
66
+ # Remove the device token from the system for this application so we don't send to it anymore
67
+ # feedback.application_name, feedback.device_token
68
+ end
69
+ end
70
+ end
71
+
72
+
73
+ Plagurism alert
74
+ ---------------
75
+
76
+ This was intended to be an extension to resque and was based heavily on resque-scheduler,
77
+ which resulted in a lot of the code looking very similar. One massive departure is the
78
+ use of logging which resque and resque-scheduler do not use but I do.
79
+
80
+
81
+ Contributing
82
+ ------------
83
+
84
+ For bugs or suggestions, please just open an issue in github.
@@ -155,11 +155,11 @@ module ResqueAps
155
155
  end
156
156
 
157
157
  def aps_read_error(exception)
158
- logger.error("ResqueAps[read_error]: #{exception} (#{application_name}): #{exception.backtrace.join("\n")}") if logger
158
+ logger.error("ResqueAps[read_error]: #{exception} (#{name}): #{exception.backtrace.join("\n")}") if logger
159
159
  end
160
160
 
161
161
  def aps_read_failed
162
- logger.error("ResqueAps[read_failed]: Bad data on the socket (#{application_name})") if logger
162
+ logger.error("ResqueAps[read_failed]: Bad data on the socket (#{name})") if logger
163
163
  end
164
164
 
165
165
  end
@@ -1,3 +1,3 @@
1
1
  module ResqueAps
2
- Version = '0.9.7'
2
+ Version = '0.9.8'
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 7
9
- version: 0.9.7
8
+ - 8
9
+ version: 0.9.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ashley Martens
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-26 00:00:00 -07:00
17
+ date: 2010-08-08 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -92,12 +92,12 @@ extensions: []
92
92
 
93
93
  extra_rdoc_files:
94
94
  - LICENSE
95
- - README
95
+ - README.markdown
96
96
  files:
97
97
  - .gitignore
98
98
  - HISTORY.md
99
99
  - LICENSE
100
- - README
100
+ - README.markdown
101
101
  - Rakefile
102
102
  - lib/resque_aps.rb
103
103
  - lib/resque_aps/application.rb
data/README DELETED
File without changes