resque-aps 0.9.3 → 0.9.4
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 +7 -0
- data/lib/resque_aps/application.rb +9 -5
- data/lib/resque_aps/server/views/aps_applications.erb +2 -3
- data/lib/resque_aps/version.rb +1 -1
- data/lib/resque_aps.rb +6 -5
- data/test/application_test.rb +22 -21
- metadata +2 -2
data/HISTORY.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## 0.9.3 (2010-07-08)
|
2
2
|
|
3
|
+
* Use redis.[rpush,lpop,lrange] commands rather than Resque.[push,pop,peek] so that Resque queues are not created for the notifications.
|
4
|
+
* Add a rescue around create_sockets to transform the exception into an application exception before raising it.
|
5
|
+
* Fix the aps_application.erb table and link to the notifications.
|
6
|
+
* Fix the application test.
|
7
|
+
|
8
|
+
## 0.9.3 (2010-07-08)
|
9
|
+
|
3
10
|
* Remove the aps_application class attribute. It's Ruby monkey patch the Application class.
|
4
11
|
|
5
12
|
## 0.9.2 (2010-07-07)
|
@@ -94,11 +94,15 @@ module ResqueAps
|
|
94
94
|
logger.debug("resque-aps: ssl_socket(#{name})") if logger
|
95
95
|
exc = nil
|
96
96
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
97
|
+
begin
|
98
|
+
socket, ssl_socket = Application.create_sockets(cert || File.read(cert_file),
|
99
|
+
certp || cert_passwd,
|
100
|
+
host || Resque.aps_gateway_host,
|
101
|
+
port || Resque.aps_gateway_port)
|
102
|
+
rescue
|
103
|
+
raise Application.application_exception($!, name)
|
104
|
+
end
|
105
|
+
|
102
106
|
begin
|
103
107
|
ssl_socket.connect
|
104
108
|
yield ssl_socket, self if block_given?
|
@@ -10,13 +10,12 @@
|
|
10
10
|
|
11
11
|
<table>
|
12
12
|
<tr>
|
13
|
-
<th></th>
|
14
13
|
<th>Application</th>
|
15
|
-
<th>Notification
|
14
|
+
<th>Notification Count</th>
|
16
15
|
</tr>
|
17
16
|
<% resque.aps_application_names(start, start+20).each do |application_name| %>
|
18
17
|
<tr>
|
19
|
-
<td><a href="<%= url "
|
18
|
+
<td><a href="<%= url "aps/#{application_name}" %>"><%= application_name %></a></td>
|
20
19
|
<td><%= resque.aps_notification_count_for_application(application_name) %></td>
|
21
20
|
</tr>
|
22
21
|
<% end %>
|
data/lib/resque_aps/version.rb
CHANGED
data/lib/resque_aps.rb
CHANGED
@@ -7,6 +7,7 @@ require 'resque_aps/version'
|
|
7
7
|
require 'resque_aps/server'
|
8
8
|
require 'resque_aps/application'
|
9
9
|
require 'resque_aps/notification'
|
10
|
+
require 'resque_aps/unknown_attribute_error'
|
10
11
|
|
11
12
|
module ResqueAps
|
12
13
|
|
@@ -72,27 +73,27 @@ module ResqueAps
|
|
72
73
|
|
73
74
|
def enqueue_aps(application_name, notification)
|
74
75
|
count = aps_notification_count_for_application(application_name)
|
75
|
-
|
76
|
+
redis.rpush(aps_application_queue_key(application_name), encode(notification.to_hash))
|
76
77
|
enqueue(ResqueAps::Application, application_name) if count <= aps_queue_size_lower || count >= aps_queue_size_upper
|
77
78
|
true
|
78
79
|
end
|
79
80
|
|
80
81
|
def dequeue_aps(application_name)
|
81
|
-
h =
|
82
|
+
h = decode(redis.lpop(aps_application_queue_key(application_name)))
|
82
83
|
return ResqueAps::Notification.new(h) if h
|
83
84
|
nil
|
84
85
|
end
|
85
86
|
|
86
87
|
# Returns the number of queued notifications for a given application
|
87
88
|
def aps_notification_count_for_application(application_name)
|
88
|
-
|
89
|
+
redis.llen(aps_application_queue_key(application_name)).to_i
|
89
90
|
end
|
90
91
|
|
91
92
|
# Returns an array of queued notifications for the given application
|
92
93
|
def aps_notifications_for_application(application_name, start = 0, count = 1)
|
93
|
-
r =
|
94
|
+
r = redis.lrange(aps_application_queue_key(application_name), start, count)
|
94
95
|
if r
|
95
|
-
r.map { |h| ResqueAps::Notification.new(h) }
|
96
|
+
r.map { |h| ResqueAps::Notification.new(decode(h)) }
|
96
97
|
else
|
97
98
|
[]
|
98
99
|
end
|
data/test/application_test.rb
CHANGED
@@ -26,33 +26,34 @@ context "ResqueAps::Application" do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
context "ApplicationWithHooks" do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
29
|
+
module ResqueAps
|
30
|
+
class Application
|
31
|
+
def before_aps_write(notification)
|
32
|
+
logger.debug "before_aps_write #{notification.inspect}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def after_aps_write(notification)
|
36
|
+
logger.debug "after_aps_write #{notification.inspect}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def failed_aps_write(notification, exception)
|
40
|
+
logger.debug "failed_aps_write #{notification.inspect}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def notify_aps_admin(exception)
|
44
|
+
logger.debug "notify_aps_admin #{exception}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def aps_nil_notification_retry?(sent_count, start_time)
|
48
|
+
logger.debug "aps_nil_notification_retry #{sent_count}"
|
49
|
+
false
|
50
|
+
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
54
|
test "can perform with logging hooks" do
|
53
55
|
n = ResqueAps::Notification.new('application_name' => 'TestApp', 'device_token' => 'aihdf08u2402hbdfquhiwr', 'payload' => '{"aps": { "alert": "hello"}}')
|
54
56
|
assert Resque.enqueue_aps('TestApp', n)
|
55
|
-
Resque.aps_application_class = ApplicationWithHooks
|
56
57
|
Resque.create_aps_application('TestApp', File.dirname(__FILE__) + "/../test-dev.pem", nil)
|
57
58
|
ResqueAps::Application.perform('TestApp')
|
58
59
|
end
|