Class: ActionPushWeb::Pool
- Inherits:
-
Object
- Object
- ActionPushWeb::Pool
- Defined in:
- lib/action_push_web/pool.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#delivery_pool ⇒ Object
readonly
Returns the value of attribute delivery_pool.
-
#invalidation_pool ⇒ Object
readonly
Returns the value of attribute invalidation_pool.
Instance Method Summary collapse
- #enqueue(notification, config:) ⇒ Object
-
#initialize(delivery_pool: Concurrent::ThreadPoolExecutor.new(max_threads: 50, queue_size: 10000), invalidation_pool: Concurrent::FixedThreadPool.new(1)) ⇒ Pool
constructor
A new instance of Pool.
- #shutdown ⇒ Object
Constructor Details
#initialize(delivery_pool: Concurrent::ThreadPoolExecutor.new(max_threads: 50, queue_size: 10000), invalidation_pool: Concurrent::FixedThreadPool.new(1)) ⇒ Pool
Returns a new instance of Pool.
5 6 7 8 9 10 |
# File 'lib/action_push_web/pool.rb', line 5 def initialize(delivery_pool: Concurrent::ThreadPoolExecutor.new(max_threads: 50, queue_size: 10000), invalidation_pool: Concurrent::FixedThreadPool.new(1)) @delivery_pool = delivery_pool @invalidation_pool = invalidation_pool @connection = Net::HTTP::Persistent.new(name: "action_push_web", pool_size: 150) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
3 4 5 |
# File 'lib/action_push_web/pool.rb', line 3 def connection @connection end |
#delivery_pool ⇒ Object (readonly)
Returns the value of attribute delivery_pool.
3 4 5 |
# File 'lib/action_push_web/pool.rb', line 3 def delivery_pool @delivery_pool end |
#invalidation_pool ⇒ Object (readonly)
Returns the value of attribute invalidation_pool.
3 4 5 |
# File 'lib/action_push_web/pool.rb', line 3 def invalidation_pool @invalidation_pool end |
Instance Method Details
#enqueue(notification, config:) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/action_push_web/pool.rb', line 12 def enqueue(notification, config:) delivery_pool.post do deliver(notification, config) end rescue Concurrent::RejectedExecutionError end |
#shutdown ⇒ Object
19 20 21 22 23 |
# File 'lib/action_push_web/pool.rb', line 19 def shutdown connection.shutdown shutdown_pool(delivery_pool) shutdown_pool(invalidation_pool) end |