Class: Upkeep::Delivery::Transport::Connection
- Inherits:
-
Object
- Object
- Upkeep::Delivery::Transport::Connection
- Defined in:
- lib/upkeep/delivery/transport.rb
Instance Attribute Summary collapse
-
#subscriber_id ⇒ Object
readonly
Returns the value of attribute subscriber_id.
Instance Method Summary collapse
- #deliver(envelope) ⇒ Object
- #disconnect ⇒ Object
-
#initialize(subscriber_id:, adapter:, max_queue_size:, retry_limit:) ⇒ Connection
constructor
A new instance of Connection.
- #queue_depth ⇒ Object
- #retry_pending ⇒ Object
Constructor Details
#initialize(subscriber_id:, adapter:, max_queue_size:, retry_limit:) ⇒ Connection
Returns a new instance of Connection.
53 54 55 56 57 58 59 |
# File 'lib/upkeep/delivery/transport.rb', line 53 def initialize(subscriber_id:, adapter:, max_queue_size:, retry_limit:) @subscriber_id = subscriber_id @adapter = adapter @max_queue_size = max_queue_size @retry_limit = retry_limit @queue = [] end |
Instance Attribute Details
#subscriber_id ⇒ Object (readonly)
Returns the value of attribute subscriber_id.
51 52 53 |
# File 'lib/upkeep/delivery/transport.rb', line 51 def subscriber_id @subscriber_id end |
Instance Method Details
#deliver(envelope) ⇒ Object
61 62 63 |
# File 'lib/upkeep/delivery/transport.rb', line 61 def deliver(envelope) deliver_envelope(envelope, attempts: 0) end |
#disconnect ⇒ Object
72 73 74 75 76 |
# File 'lib/upkeep/delivery/transport.rb', line 72 def disconnect dropped = @queue.size @queue = [] dropped end |
#queue_depth ⇒ Object
78 79 80 |
# File 'lib/upkeep/delivery/transport.rb', line 78 def queue_depth @queue.size end |
#retry_pending ⇒ Object
65 66 67 68 69 70 |
# File 'lib/upkeep/delivery/transport.rb', line 65 def retry_pending pending = @queue @queue = [] pending.map { |item| deliver_envelope(item.envelope, attempts: item.attempts) } end |