notify_user 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77798252ab441cbfca131b125e40292b701210dd
4
- data.tar.gz: 5cc16d6d5c354588db35b6a0797ce61da23a669d
3
+ metadata.gz: 8d21b220862a946109126fd399260454de810107
4
+ data.tar.gz: 84d380d7553c60678ccaaf4846f71570c41d3d2c
5
5
  SHA512:
6
- metadata.gz: fdb8a7efaa8c5e7af6bc9b8a84ae0189ce564c4492d25d8cb00c991a1964df787e00a392e77cea452c358e34380bc785d4638177304dd74df052a5d0ddc90d7c
7
- data.tar.gz: 13e3307a5e50a15aade5b029bdf9483b3d20df4bd1b704b6057c2ba60dd30dc36433f14542520c5b0203cb485f5afe5f01a55304e19b79d601cf2f5160a1d710
6
+ metadata.gz: 957169fda235cd41be58726384b17f9a03b4981c2611878daf07d09a346dad9d0b8bb57f7c3ed49664e79f1bdb4750f4e2fa76ed4b3dfcde9662888fd3f7e3c7
7
+ data.tar.gz: 0ec1c8ff6731c5c0769f1f5e372331728049e8be4c36130583bee81e86b6216b73ef43f7fa781ad9907c9e287de91bac02766fa7ff5c232e2fb5620c3712f450
data/README.md CHANGED
@@ -53,17 +53,6 @@ wwtd
53
53
  ## APNS providers
54
54
  By default, we use [Houston](https://github.com/nomad/houston/) to deliver push notifications via APNS from the server.
55
55
 
56
- The initialiser for `notify_user` contains the following configuration when delivering via Houston:
57
- ```
58
- # Number of connections Houston will maintain to APNS:
59
- config.connection_pool_size = 3
60
-
61
- # Time in seconds Houston will wait for a free connection before failing:
62
- config.connection_pool_timeout = 300
63
- ```
64
-
65
- We maintain persistent connections to APNS via background workers, and these values will allow you to configure how many connections the workers maintain, as well as the amount of time to wait for an idle connection before timing out.
66
-
67
56
  You also need to provide exported versions of your push notification certificate and key as .pem files, these instructions come from the [APN on Rails](https://github.com/PRX/apn_on_rails) project on how to do that:
68
57
 
69
58
  Once you have the certificate from Apple for your application, export your key
@@ -1,6 +1,10 @@
1
1
  module NotifyUser
2
2
  class APNConnection
3
3
 
4
+ POOL = ConnectionPool.new(size: ENV['APNS_CONNECTION_POOL_SIZE'] || 1, timeout: ENV['APNS_CONNECTION_TIMEOUT'] || 30) {
5
+ APNConnection.new
6
+ }
7
+
4
8
  def initialize
5
9
  connection
6
10
  end
@@ -5,9 +5,8 @@ module NotifyUser
5
5
  class Apns < Push
6
6
  NO_ERROR = -42
7
7
  INVALID_TOKEN_ERROR = 8
8
- CONNECTION = APNConnection.new
9
8
 
10
- attr_accessor :push_options
9
+ attr_accessor :push_options, :apn_connection
11
10
 
12
11
  def initialize(notifications, devices, options)
13
12
  super(notifications, devices, options)
@@ -17,7 +16,10 @@ module NotifyUser
17
16
  end
18
17
 
19
18
  def push
20
- send_notifications
19
+ APNConnection::POOL.with do |apn_conn|
20
+ @apn_connection = apn_conn
21
+ send_notifications
22
+ end
21
23
  end
22
24
 
23
25
  private
@@ -25,11 +27,11 @@ module NotifyUser
25
27
  attr_accessor :devices
26
28
 
27
29
  def connection
28
- CONNECTION.connection
30
+ apn_connection.connection
29
31
  end
30
32
 
31
33
  def reset_connection
32
- CONNECTION.reset
34
+ apn_connection.reset
33
35
  end
34
36
 
35
37
  def setup_options
@@ -14,11 +14,4 @@ NotifyUser.setup do |config|
14
14
 
15
15
  # Provider for APNS:
16
16
  config.apns_provider = :houston
17
-
18
- # Number of connections Houston will maintain to APNS:
19
- config.connection_pool_size = 3
20
-
21
- # Time in seconds Houston will wait for a free connection before failing:
22
- config.connection_pool_timeout = 300
23
-
24
17
  end
@@ -20,14 +20,6 @@ module NotifyUser
20
20
  mattr_accessor :apns_provider
21
21
  @@apns_provider = nil
22
22
 
23
- # Number of connections Houston will maintain to APNS:
24
- mattr_accessor :connection_pool_size
25
- @@connection_pool_size = nil
26
-
27
- # Time in seconds Houston will wait for a free connection before failing:
28
- mattr_accessor :connection_pool_timeout
29
- @@connection_pool_timeout = nil
30
-
31
23
  # Used to set up NotifyUser from the initializer.
32
24
  def self.setup
33
25
  yield self
@@ -1,3 +1,3 @@
1
1
  module NotifyUser
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notify_user
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Spacek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-19 00:00:00.000000000 Z
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails