Class: MessageBus::Backends::Memory::Client::Channel
- Inherits:
-
Object
- Object
- MessageBus::Backends::Memory::Client::Channel
- Defined in:
- lib/message_bus/backends/memory.rb
Instance Attribute Summary collapse
-
#backlog ⇒ Object
Returns the value of attribute backlog.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(ttl:) ⇒ Channel
constructor
A new instance of Channel.
Constructor Details
#initialize(ttl:) ⇒ Channel
Returns a new instance of Channel.
37 38 39 40 |
# File 'lib/message_bus/backends/memory.rb', line 37 def initialize(ttl:) @backlog = [] @ttl = ttl end |
Instance Attribute Details
#backlog ⇒ Object
Returns the value of attribute backlog.
35 36 37 |
# File 'lib/message_bus/backends/memory.rb', line 35 def backlog @backlog end |
#ttl ⇒ Object
Returns the value of attribute ttl.
35 36 37 |
# File 'lib/message_bus/backends/memory.rb', line 35 def ttl @ttl end |
Instance Method Details
#expired? ⇒ Boolean
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/message_bus/backends/memory.rb', line 42 def expired? last_publication_time = nil backlog.each do |_id, _value, published_at| if !last_publication_time || published_at > last_publication_time last_publication_time = published_at end end return true unless last_publication_time last_publication_time < Time.now - ttl end |