Class: EventSourcery::EventStore::PollWaiter
- Inherits:
-
Object
- Object
- EventSourcery::EventStore::PollWaiter
- Defined in:
- lib/event_sourcery/event_store/poll_waiter.rb
Overview
This class provides a basic poll waiter implementation that calls the provided block and sleeps for the specified interval, to be used by a Subscription.
Instance Method Summary collapse
-
#initialize(interval: 0.5) ⇒ PollWaiter
constructor
A new instance of PollWaiter.
-
#poll(&block) ⇒ Object
Start polling.
Constructor Details
#initialize(interval: 0.5) ⇒ PollWaiter
Returns a new instance of PollWaiter.
8 9 10 |
# File 'lib/event_sourcery/event_store/poll_waiter.rb', line 8 def initialize(interval: 0.5) @interval = interval end |
Instance Method Details
#poll(&block) ⇒ Object
Start polling. Call the provided block and sleep. Repeat until ‘:stop` is thrown (usually via a subscription master).
18 19 20 21 22 23 24 25 |
# File 'lib/event_sourcery/event_store/poll_waiter.rb', line 18 def poll(&block) catch(:stop) do loop do block.call sleep @interval end end end |