rpush 2.3.2-java → 2.4.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +1 -1
- data/lib/generators/rpush_migration_generator.rb +21 -6
- data/lib/generators/templates/rpush.rb +5 -5
- data/lib/generators/templates/rpush_2_0_0_updates.rb +24 -0
- data/lib/rpush/client/active_model/apns/notification.rb +1 -1
- data/lib/rpush/client/mongoid/adm/app.rb +14 -0
- data/lib/rpush/client/mongoid/adm/notification.rb +11 -0
- data/lib/rpush/client/mongoid/apns/app.rb +11 -0
- data/lib/rpush/client/mongoid/apns/feedback.rb +21 -0
- data/lib/rpush/client/mongoid/apns/notification.rb +15 -0
- data/lib/rpush/client/mongoid/app.rb +23 -0
- data/lib/rpush/client/mongoid/gcm/app.rb +11 -0
- data/lib/rpush/client/mongoid/gcm/notification.rb +11 -0
- data/lib/rpush/client/mongoid/notification.rb +43 -0
- data/lib/rpush/client/mongoid/wpns/app.rb +11 -0
- data/lib/rpush/client/mongoid/wpns/notification.rb +11 -0
- data/lib/rpush/client/mongoid.rb +31 -0
- data/lib/rpush/client/redis.rb +2 -2
- data/lib/rpush/configuration.rb +48 -29
- data/lib/rpush/daemon/adm/delivery.rb +1 -1
- data/lib/rpush/daemon/apns/feedback_receiver.rb +2 -3
- data/lib/rpush/daemon/apns.rb +1 -1
- data/lib/rpush/daemon/dispatcher/apns_tcp.rb +2 -1
- data/lib/rpush/daemon/feeder.rb +4 -7
- data/lib/rpush/daemon/gcm/delivery.rb +1 -1
- data/lib/rpush/daemon/interruptible_sleep.rb +5 -50
- data/lib/rpush/daemon/proc_title.rb +2 -1
- data/lib/rpush/daemon/store/active_record.rb +4 -0
- data/lib/rpush/daemon/store/interface.rb +1 -1
- data/lib/rpush/daemon/store/mongoid.rb +157 -0
- data/lib/rpush/daemon/store/redis.rb +6 -2
- data/lib/rpush/deprecatable.rb +1 -2
- data/lib/rpush/deprecation.rb +6 -0
- data/lib/rpush/embed.rb +5 -0
- data/lib/rpush/logger.rb +5 -8
- data/lib/rpush/push.rb +5 -0
- data/lib/rpush/version.rb +1 -1
- data/lib/tasks/quality.rake +1 -1
- data/lib/tasks/test.rake +9 -4
- data/spec/functional/apns_spec.rb +2 -1
- data/spec/functional_spec_helper.rb +2 -2
- data/spec/spec_helper.rb +18 -7
- data/spec/support/config/mongoid.yml +69 -0
- data/spec/support/mongoid_setup.rb +10 -0
- data/spec/unit/client/active_record/adm/app_spec.rb +1 -1
- data/spec/unit/client/active_record/adm/notification_spec.rb +1 -1
- data/spec/unit/client/active_record/apns/app_spec.rb +1 -1
- data/spec/unit/client/active_record/apns/feedback_spec.rb +1 -1
- data/spec/unit/client/active_record/apns/notification_spec.rb +11 -11
- data/spec/unit/client/active_record/app_spec.rb +1 -1
- data/spec/unit/client/active_record/gcm/notification_spec.rb +1 -1
- data/spec/unit/client/active_record/notification_spec.rb +1 -1
- data/spec/unit/client/active_record/wpns/notification_spec.rb +1 -1
- data/spec/unit/configuration_spec.rb +7 -0
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +5 -5
- data/spec/unit/daemon/feeder_spec.rb +2 -2
- data/spec/unit/daemon/proc_title_spec.rb +11 -0
- data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +1 -1
- data/spec/unit/daemon/store/active_record_spec.rb +21 -12
- data/spec/unit/daemon/store/mongoid_spec.rb +339 -0
- data/spec/unit/daemon/store/redis_spec.rb +365 -0
- data/spec/unit/embed_spec.rb +4 -2
- data/spec/unit/logger_spec.rb +14 -5
- data/spec/unit/notification_shared.rb +1 -1
- data/spec/unit/push_spec.rb +4 -2
- data/spec/unit_spec_helper.rb +3 -3
- metadata +27 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49a209aeb1cf3b46511c9376fb0f35ba4ca1398e
|
4
|
+
data.tar.gz: c1402f1adf30cbb8c3fa2a81f1851920d0b4271d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecea38aeb595d81a6b45ca2c83a9c4e45592e3fdc03022872948892153db560ac0719134d51823b188d1cde2e7f39709706497f3af37b30499b73acf5c176c58
|
7
|
+
data.tar.gz: 80229d942221cd34f38ae7a8a9684b102e7954cfb0201b7dd5eb63bfbdd9d6f05a4f87e0413b7fd857254fbc44df17ec5ed84d9a56d28622fc98f69c6a776f8f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 2.4.0 (Fed 18, 2015)
|
2
|
+
Features:
|
3
|
+
* Support for MongoDB (using Mongoid).
|
4
|
+
* config.feedback_poll is now deprecated, use config.apns.feedback_receiver.frequency instead.
|
5
|
+
* Add config.apns.feedback_receiver.enabled to optionally enable the APNs feedback receiver (#129).
|
6
|
+
* Passing configuration options directly to Rpush.embed and Rpush.push is now deprecated.
|
7
|
+
|
8
|
+
Bug fixes:
|
9
|
+
* Fix setting the log level when using Rails 4+ or without Rails (#124).
|
10
|
+
* Fix the possibility for excessive error logging when using APNs (#128).
|
11
|
+
* Re-use timestamp when replacing a migration with the same name (#91).
|
12
|
+
* Ensure App/Notification type is updated during 2.0 upgrade migration (#102).
|
13
|
+
|
1
14
|
## 2.3.2 (Jan 30, 2015)
|
2
15
|
Bug fixes:
|
3
16
|
* Internal sleep mechanism would sometimes no wait for the full duration specified.
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ Rpush aims to be the *de facto* gem for sending push notifications in Ruby. Its
|
|
19
19
|
|
20
20
|
#### Feature Highlights
|
21
21
|
|
22
|
-
* Use [**ActiveRecord**](https://github.com/rpush/rpush/wiki/Using-ActiveRecord)
|
22
|
+
* Use [**ActiveRecord**](https://github.com/rpush/rpush/wiki/Using-ActiveRecord), [**Redis**](https://github.com/rpush/rpush/wiki/Using-Redis) or [**MongoDB**](https://github.com/rpush/rpush/wiki/Using-Mongodb) for storage.
|
23
23
|
* Plugins for [**Bugsnag**](https://github.com/rpush/rpush-plugin-bugsnag),
|
24
24
|
[**Sentry**](https://github.com/rpush/rpush-plugin-sentry), [**StatsD**](https://github.com/rpush/rpush-plugin-statsd).
|
25
25
|
* Seamless integration with your projects, including **Rails**.
|
@@ -2,11 +2,25 @@ class RpushMigrationGenerator < Rails::Generators::Base
|
|
2
2
|
include Rails::Generators::Migration
|
3
3
|
source_root File.expand_path('../templates', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
class << self
|
6
|
+
attr_accessor :next_template
|
7
|
+
|
8
|
+
def next_migration_number(path)
|
9
|
+
return new_migration_number unless next_template
|
10
|
+
|
11
|
+
if existing_migration = migration_exists?(File.expand_path('db/migrate'), next_template)
|
12
|
+
return File.basename(existing_migration).scan(/(\d+)_/).flatten.first
|
13
|
+
end
|
14
|
+
|
15
|
+
new_migration_number
|
16
|
+
end
|
17
|
+
|
18
|
+
def new_migration_number
|
19
|
+
@time ||= Time.now.utc
|
20
|
+
@calls ||= -1
|
21
|
+
@calls += 1
|
22
|
+
(@time + @calls.seconds).strftime('%Y%m%d%H%M%S')
|
23
|
+
end
|
10
24
|
end
|
11
25
|
|
12
26
|
def copy_migration
|
@@ -36,6 +50,7 @@ class RpushMigrationGenerator < Rails::Generators::Base
|
|
36
50
|
end
|
37
51
|
|
38
52
|
def add_rpush_migration(template)
|
39
|
-
|
53
|
+
self.class.next_template = template
|
54
|
+
migration_template "#{template}.rb", "db/migrate/#{template}.rb"
|
40
55
|
end
|
41
56
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Rpush.configure do |config|
|
2
2
|
|
3
|
-
# Supported clients are :active_record and :
|
3
|
+
# Supported clients are :active_record, :redis and :mongoid
|
4
4
|
config.client = :active_record
|
5
5
|
|
6
6
|
# Options passed to Redis.new
|
@@ -9,9 +9,6 @@ Rpush.configure do |config|
|
|
9
9
|
# Frequency in seconds to check for new notifications.
|
10
10
|
config.push_poll = 2
|
11
11
|
|
12
|
-
# Frequency in seconds to check for feedback
|
13
|
-
config.feedback_poll = 60
|
14
|
-
|
15
12
|
# The maximum number of notifications to load from the store every `push_poll` seconds.
|
16
13
|
# If some notifications are still enqueued internally, Rpush will load the batch_size less
|
17
14
|
# the number enqueued. An exception to this is if the service is able to receive multiple
|
@@ -24,11 +21,14 @@ Rpush.configure do |config|
|
|
24
21
|
# Path to log file. Relative to current directory unless absolute.
|
25
22
|
config.log_file = 'log/rpush.log'
|
26
23
|
|
27
|
-
config.log_level = (defined?(Rails) && Rails.logger) ? Rails.logger.level : ::Logger::Severity::
|
24
|
+
config.log_level = (defined?(Rails) && Rails.logger) ? Rails.logger.level : ::Logger::Severity::DEBUG
|
28
25
|
|
29
26
|
# Define a custom logger.
|
30
27
|
# config.logger = MyLogger.new
|
31
28
|
|
29
|
+
# config.apns.feedback_receiver.enabled = true
|
30
|
+
# config.apns.feedback_receiver.frequency = 60
|
31
|
+
|
32
32
|
end
|
33
33
|
|
34
34
|
Rpush.reflect do |on|
|
@@ -1,4 +1,18 @@
|
|
1
1
|
class Rpush200Updates < ActiveRecord::Migration
|
2
|
+
module Rpush
|
3
|
+
class App < ActiveRecord::Base
|
4
|
+
self.table_name = 'rpush_apps'
|
5
|
+
end
|
6
|
+
|
7
|
+
class Notification < ActiveRecord::Base
|
8
|
+
self.table_name = 'rpush_notifications'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.update_type(model, from, to)
|
13
|
+
model.where(type: from).update_all(type: to)
|
14
|
+
end
|
15
|
+
|
2
16
|
def self.up
|
3
17
|
add_column :rpush_notifications, :processing, :boolean, null: false, default: false
|
4
18
|
add_column :rpush_notifications, :priority, :integer, null: true
|
@@ -16,9 +30,19 @@ class Rpush200Updates < ActiveRecord::Migration
|
|
16
30
|
else
|
17
31
|
change_column :rpush_feedback, :app_id, :integer
|
18
32
|
end
|
33
|
+
|
34
|
+
[:Apns, :Gcm, :Wpns, :Adm].each do |service|
|
35
|
+
update_type(Rpush200Updates::Rpush::App, "Rpush::#{service}::App", "Rpush::Client::ActiveRecord::#{service}::App")
|
36
|
+
update_type(Rpush200Updates::Rpush::Notification, "Rpush::#{service}::Notification", "Rpush::Client::ActiveRecord::#{service}::Notification")
|
37
|
+
end
|
19
38
|
end
|
20
39
|
|
21
40
|
def self.down
|
41
|
+
[:Apns, :Gcm, :Wpns, :Adm].each do |service|
|
42
|
+
update_type(Rpush200Updates::Rpush::App, "Rpush::Client::ActiveRecord::#{service}::App", "Rpush::#{service}::App")
|
43
|
+
update_type(Rpush200Updates::Rpush::Notification, "Rpush::Client::ActiveRecord::#{service}::Notification", "Rpush::#{service}::Notification")
|
44
|
+
end
|
45
|
+
|
22
46
|
change_column :rpush_feedback, :app_id, :string
|
23
47
|
rename_column :rpush_feedback, :app_id, :app
|
24
48
|
|
@@ -66,7 +66,7 @@ module Rpush
|
|
66
66
|
|
67
67
|
def to_binary(options = {}) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
|
68
68
|
frame_payload = payload
|
69
|
-
frame_id = options[:for_validation] ? 0 : id
|
69
|
+
frame_id = options[:for_validation] ? 0 : send(options.fetch(:id_attribute, :id))
|
70
70
|
frame = ""
|
71
71
|
frame << [1, 32, device_token].pack("cnH*")
|
72
72
|
frame << [2, frame_payload.bytesize, frame_payload].pack("cna*")
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Mongoid
|
4
|
+
module Adm
|
5
|
+
class App < Rpush::Client::Mongoid::App
|
6
|
+
include Rpush::Client::ActiveModel::Adm::App
|
7
|
+
|
8
|
+
field :access_token, type: String
|
9
|
+
field :access_token_expiration, type: Time
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Mongoid
|
4
|
+
module Apns
|
5
|
+
class Feedback
|
6
|
+
include ::Mongoid::Document
|
7
|
+
|
8
|
+
field :device_token, type: String
|
9
|
+
field :failed_at, type: Time
|
10
|
+
|
11
|
+
belongs_to :app
|
12
|
+
|
13
|
+
validates :device_token, presence: true
|
14
|
+
validates :failed_at, presence: true
|
15
|
+
|
16
|
+
validates_with Rpush::Client::ActiveModel::Apns::DeviceTokenFormatValidator
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Mongoid
|
4
|
+
module Apns
|
5
|
+
class Notification < Rpush::Client::Mongoid::Notification
|
6
|
+
include Rpush::Client::ActiveModel::Apns::Notification
|
7
|
+
|
8
|
+
def to_binary(options = {})
|
9
|
+
super(options.merge(id_attribute: :integer_id))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Mongoid
|
4
|
+
class App
|
5
|
+
include ::Mongoid::Document
|
6
|
+
|
7
|
+
field :name, type: String
|
8
|
+
field :environment, type: String
|
9
|
+
field :certificate, type: String
|
10
|
+
field :password, type: String
|
11
|
+
field :connections, type: Integer, default: 1
|
12
|
+
field :auth_key, type: String
|
13
|
+
field :client_id, type: String
|
14
|
+
field :client_secret, type: String
|
15
|
+
|
16
|
+
index name: 1
|
17
|
+
|
18
|
+
validates :name, presence: true
|
19
|
+
validates_numericality_of :connections, greater_than: 0, only_integer: true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Mongoid
|
4
|
+
class Notification
|
5
|
+
include ::Mongoid::Document
|
6
|
+
include ::Mongoid::Autoinc
|
7
|
+
include Rpush::MultiJsonHelper
|
8
|
+
include Rpush::Client::ActiveModel::Notification
|
9
|
+
|
10
|
+
field :badge, type: Integer
|
11
|
+
field :device_token, type: String
|
12
|
+
field :sound, type: String, default: 'default'
|
13
|
+
field :alert, type: String
|
14
|
+
field :data, type: Hash
|
15
|
+
field :expiry, type: Integer, default: 1.day.to_i
|
16
|
+
field :delivered, type: Boolean, default: false
|
17
|
+
field :delivered_at, type: Time
|
18
|
+
field :processing, type: Boolean, default: false
|
19
|
+
field :failed, type: Boolean, default: false
|
20
|
+
field :failed_at, type: Time
|
21
|
+
field :fail_after, type: Time
|
22
|
+
field :retries, type: Integer, default: 0
|
23
|
+
field :error_code, type: Integer
|
24
|
+
field :error_description, type: String
|
25
|
+
field :deliver_after, type: Time
|
26
|
+
field :alert_is_json, type: Boolean
|
27
|
+
field :collapse_key, type: String
|
28
|
+
field :delay_while_idle, type: Boolean
|
29
|
+
field :registration_ids, type: Array
|
30
|
+
field :uri, type: String
|
31
|
+
field :priority, type: Integer
|
32
|
+
field :url_args, type: Array
|
33
|
+
field :category, type: String
|
34
|
+
|
35
|
+
field :integer_id, type: Integer
|
36
|
+
increments :integer_id, model_name: name
|
37
|
+
index integer_id: 1
|
38
|
+
|
39
|
+
belongs_to :app
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
# :nocov:
|
3
|
+
begin
|
4
|
+
require 'mongoid'
|
5
|
+
require 'autoinc'
|
6
|
+
rescue LoadError
|
7
|
+
puts
|
8
|
+
str = "* Please add 'rpush-mongoid' to your Gemfile to use the Mongoid client. *"
|
9
|
+
puts "*" * str.size
|
10
|
+
puts str
|
11
|
+
puts "*" * str.size
|
12
|
+
puts
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'rpush/client/active_model'
|
16
|
+
|
17
|
+
require 'rpush/client/mongoid/notification'
|
18
|
+
require 'rpush/client/mongoid/app'
|
19
|
+
|
20
|
+
require 'rpush/client/mongoid/apns/notification'
|
21
|
+
require 'rpush/client/mongoid/apns/feedback'
|
22
|
+
require 'rpush/client/mongoid/apns/app'
|
23
|
+
|
24
|
+
require 'rpush/client/mongoid/gcm/notification'
|
25
|
+
require 'rpush/client/mongoid/gcm/app'
|
26
|
+
|
27
|
+
require 'rpush/client/mongoid/wpns/notification'
|
28
|
+
require 'rpush/client/mongoid/wpns/app'
|
29
|
+
|
30
|
+
require 'rpush/client/mongoid/adm/notification'
|
31
|
+
require 'rpush/client/mongoid/adm/app'
|
data/lib/rpush/client/redis.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
|
1
2
|
# :nocov:
|
2
3
|
begin
|
3
4
|
require 'modis'
|
5
|
+
require 'redis'
|
4
6
|
rescue LoadError
|
5
7
|
puts
|
6
8
|
str = "* Please add 'rpush-redis' to your Gemfile to use the Redis client. *"
|
@@ -10,8 +12,6 @@ rescue LoadError
|
|
10
12
|
puts
|
11
13
|
end
|
12
14
|
|
13
|
-
require 'redis'
|
14
|
-
|
15
15
|
require 'rpush/client/active_model'
|
16
16
|
|
17
17
|
require 'rpush/client/redis/app'
|
data/lib/rpush/configuration.rb
CHANGED
@@ -1,35 +1,64 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
|
3
3
|
module Rpush
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class << self
|
5
|
+
attr_writer :config
|
6
|
+
|
7
|
+
def config
|
8
|
+
@config ||= Rpush::Configuration.new
|
9
|
+
end
|
7
10
|
|
8
|
-
|
9
|
-
|
11
|
+
def configure
|
12
|
+
return unless block_given?
|
10
13
|
yield config
|
11
14
|
config.initialize_client
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
15
|
-
CURRENT_ATTRS = [:push_poll, :
|
16
|
-
|
17
|
-
DEPRECATED_ATTRS = [:log_dir]
|
18
|
+
CURRENT_ATTRS = [:push_poll, :embedded, :pid_file, :batch_size, :push, :client, :logger, :log_file, :foreground, :log_level, :plugin, :apns]
|
19
|
+
DEPRECATED_ATTRS = [:feedback_poll]
|
18
20
|
CONFIG_ATTRS = CURRENT_ATTRS + DEPRECATED_ATTRS
|
19
21
|
|
20
22
|
class ConfigurationError < StandardError; end
|
21
|
-
class ConfigurationWithoutDefaults < Struct.new(*CONFIG_ATTRS); end
|
23
|
+
class ConfigurationWithoutDefaults < Struct.new(*CONFIG_ATTRS); end # rubocop:disable Style/StructInheritance
|
22
24
|
|
23
|
-
class
|
24
|
-
|
25
|
+
class ApnsFeedbackReceiverConfiguration < Struct.new(:frequency, :enabled) # rubocop:disable Style/StructInheritance
|
26
|
+
def initialize
|
27
|
+
super
|
28
|
+
self.enabled = true
|
29
|
+
self.frequency = 60
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class ApnsConfiguration < Struct.new(:feedback_receiver) # rubocop:disable Style/StructInheritance
|
34
|
+
def initialize
|
35
|
+
super
|
36
|
+
self.feedback_receiver = ApnsFeedbackReceiverConfiguration.new
|
37
|
+
end
|
38
|
+
end
|
25
39
|
|
26
|
-
|
40
|
+
class Configuration < Struct.new(*CONFIG_ATTRS) # rubocop:disable Style/StructInheritance
|
41
|
+
include Deprecatable
|
27
42
|
|
28
43
|
delegate :redis_options, to: '::Modis'
|
29
44
|
|
30
45
|
def initialize
|
31
46
|
super
|
32
|
-
|
47
|
+
|
48
|
+
self.push_poll = 2
|
49
|
+
self.batch_size = 100
|
50
|
+
self.logger = nil
|
51
|
+
self.log_file = 'log/rpush.log'
|
52
|
+
self.pid_file = 'tmp/rpush.pid'
|
53
|
+
self.log_level = (defined?(Rails) && Rails.logger) ? Rails.logger.level : ::Logger::Severity::DEBUG
|
54
|
+
self.plugin = OpenStruct.new
|
55
|
+
self.foreground = false
|
56
|
+
|
57
|
+
self.apns = ApnsConfiguration.new
|
58
|
+
|
59
|
+
# Internal options.
|
60
|
+
self.embedded = false
|
61
|
+
self.push = false
|
33
62
|
end
|
34
63
|
|
35
64
|
def update(other)
|
@@ -68,31 +97,21 @@ module Rpush
|
|
68
97
|
Modis.redis_options = options if client == :redis
|
69
98
|
end
|
70
99
|
|
71
|
-
def
|
72
|
-
|
73
|
-
self.feedback_poll = 60
|
74
|
-
self.batch_size = 100
|
75
|
-
self.logger = nil
|
76
|
-
self.log_file = 'log/rpush.log'
|
77
|
-
self.pid_file = 'tmp/rpush.pid'
|
78
|
-
self.log_level = (defined?(Rails) && Rails.logger) ? Rails.logger.level : ::Logger::Severity::INFO
|
79
|
-
self.plugin = OpenStruct.new
|
80
|
-
self.foreground = false
|
81
|
-
|
82
|
-
# Internal options.
|
83
|
-
self.embedded = false
|
84
|
-
self.push = false
|
100
|
+
def feedback_poll=(frequency)
|
101
|
+
apns.feedback_receiver.frequency = frequency
|
85
102
|
end
|
103
|
+
deprecated(:feedback_poll=, '2.5.0', 'Please use apns.feedback_receiver.frequency= instead.')
|
86
104
|
|
87
105
|
def initialize_client
|
88
106
|
return if @client_initialized
|
89
107
|
raise ConfigurationError, 'Rpush.config.client is not set.' unless client
|
90
108
|
require "rpush/client/#{client}"
|
109
|
+
|
91
110
|
client_module = Rpush::Client.const_get(client.to_s.camelize)
|
92
|
-
Rpush.send(:include, client_module)
|
111
|
+
Rpush.send(:include, client_module) unless Rpush.ancestors.include?(client_module)
|
93
112
|
|
94
113
|
[:Apns, :Gcm, :Wpns, :Adm].each do |service|
|
95
|
-
Rpush.const_set(service, client_module.const_get(service))
|
114
|
+
Rpush.const_set(service, client_module.const_get(service)) unless Rpush.const_defined?(service)
|
96
115
|
end
|
97
116
|
|
98
117
|
@client_initialized = true
|
@@ -151,7 +151,7 @@ module Rpush
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def create_new_notification(response, registration_ids)
|
154
|
-
attrs = @notification.
|
154
|
+
attrs = { 'app_id' => @notification.app_id, 'collapse_key' => @notification.collapse_key, 'delay_while_idle' => @notification.delay_while_idle }
|
155
155
|
Rpush::Daemon.store.create_adm_notification(attrs, @notification.data, registration_ids, deliver_after_header(response), @notification.app)
|
156
156
|
end
|
157
157
|
|
@@ -19,19 +19,18 @@ module Rpush
|
|
19
19
|
@host, @port = HOSTS[@app.environment.to_sym]
|
20
20
|
@certificate = app.certificate
|
21
21
|
@password = app.password
|
22
|
-
@interruptible_sleep = InterruptibleSleep.new
|
22
|
+
@interruptible_sleep = InterruptibleSleep.new
|
23
23
|
end
|
24
24
|
|
25
25
|
def start
|
26
26
|
return if Rpush.config.push
|
27
27
|
Rpush.logger.info("[#{@app.name}] Starting feedback receiver... ", true)
|
28
|
-
@interruptible_sleep.start
|
29
28
|
|
30
29
|
@thread = Thread.new do
|
31
30
|
loop do
|
32
31
|
break if @stop
|
33
32
|
check_for_feedback
|
34
|
-
@interruptible_sleep.sleep
|
33
|
+
@interruptible_sleep.sleep(Rpush.config.apns.feedback_receiver.frequency)
|
35
34
|
end
|
36
35
|
|
37
36
|
Rpush::Daemon.store.release_connection
|
data/lib/rpush/daemon/apns.rb
CHANGED
@@ -11,7 +11,7 @@ module Rpush
|
|
11
11
|
|
12
12
|
batch_deliveries true
|
13
13
|
dispatcher :apns_tcp, host: proc { |app| HOSTS[app.environment.to_sym] }
|
14
|
-
loops Rpush::Daemon::Apns::FeedbackReceiver, if: -> { !Rpush.config.push }
|
14
|
+
loops Rpush::Daemon::Apns::FeedbackReceiver, if: -> { Rpush.config.apns.feedback_receiver.enabled && !Rpush.config.push }
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -63,7 +63,7 @@ module Rpush
|
|
63
63
|
# On Linux, select returns nil from a dropped connection.
|
64
64
|
# On OS X, Errno::EBADF is raised following a Errno::EADDRNOTAVAIL from the write call.
|
65
65
|
return unless @connection.select(SELECT_TIMEOUT)
|
66
|
-
rescue SystemCallError
|
66
|
+
rescue SystemCallError, IOError
|
67
67
|
# Connection closed.
|
68
68
|
return
|
69
69
|
end
|
@@ -93,6 +93,7 @@ module Rpush
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def handle_error(code, notification_id)
|
96
|
+
notification_id = Rpush::Daemon.store.translate_integer_notification_id(notification_id)
|
96
97
|
failed_pos = delivered_buffer.index(notification_id)
|
97
98
|
description = APNS_ERRORS[code.to_i] || "Unknown error code #{code.inspect}. Possible Rpush bug?"
|
98
99
|
log_error(description + " (#{code})")
|
data/lib/rpush/daemon/feeder.rb
CHANGED
@@ -21,7 +21,7 @@ module Rpush
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.wakeup
|
24
|
-
interruptible_sleeper.
|
24
|
+
interruptible_sleeper.stop
|
25
25
|
end
|
26
26
|
|
27
27
|
class << self
|
@@ -35,8 +35,8 @@ module Rpush
|
|
35
35
|
def self.feed_forever
|
36
36
|
loop do
|
37
37
|
enqueue_notifications
|
38
|
-
interruptible_sleeper.sleep
|
39
|
-
|
38
|
+
interruptible_sleeper.sleep(Rpush.config.push_poll)
|
39
|
+
return if should_stop
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -51,10 +51,7 @@ module Rpush
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def self.interruptible_sleeper
|
54
|
-
|
55
|
-
@interruptible_sleeper = InterruptibleSleep.new(Rpush.config.push_poll)
|
56
|
-
@interruptible_sleeper.start
|
57
|
-
@interruptible_sleeper
|
54
|
+
@interruptible_sleeper ||= InterruptibleSleep.new
|
58
55
|
end
|
59
56
|
end
|
60
57
|
end
|
@@ -100,7 +100,7 @@ module Rpush
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def create_new_notification(response, unavailable_idxs)
|
103
|
-
attrs = @notification.
|
103
|
+
attrs = { 'app_id' => @notification.app_id, 'collapse_key' => @notification.collapse_key, 'delay_while_idle' => @notification.delay_while_idle }
|
104
104
|
registration_ids = @notification.registration_ids.values_at(*unavailable_idxs)
|
105
105
|
Rpush::Daemon.store.create_gcm_notification(attrs, @notification.data,
|
106
106
|
registration_ids, deliver_after_header(response), @notification.app)
|