Module: Qup
- Defined in:
- lib/qup/batch_consumer.rb,
lib/qup.rb,
lib/qup/adapter.rb,
lib/qup/message.rb,
lib/qup/session.rb,
lib/qup/consumer.rb,
lib/qup/producer.rb,
lib/qup/publisher.rb,
lib/qup/queue_api.rb,
lib/qup/topic_api.rb,
lib/qup/subscriber.rb,
lib/qup/backoff_sleeper.rb
Overview
Used to sleep for exponentially increasing amounts of time between successive unsuccessful attempts to do something like poll for queue data or reconnect to a client. Maxes out at 1 second between attempts.
Call #tick in every iteration of the task you are trying to accomplish. When a successful iteration is completed (for example the queue had data, or connecting was successful) call #reset to let the sleeper know that it can reset the amount of time between attempts back to 0. The sleeper will not call Kernel#sleep if it #reset was just called, so it is safe to call #tick on every iteration, provided that you call #reset on success before calling #tick.
Examples:
sleeper = BackoffSleeper.new
loop do
=
sleeper.reset unless .nil?
sleeper.tick
end
Defined Under Namespace
Modules: BatchConsumerAPI, QueueAPI, TopicAPI Classes: Adapter, BackoffSleeper, BatchConsumer, Consumer, Error, Message, Producer, Publisher, Session, Subscriber
Constant Summary collapse
- VERSION =
The Current Version of the library
'1.4.0'
- KNOWN_ADAPTERS =
{ # require => gem 'maildir' => 'maildir', 'kestrel' => 'kjess', 'redis' => 'redis' }
- Adapters =
The list of registered Adapters
Hash.new
Class Method Summary collapse
-
.open(uri, &block) ⇒ Object
Public: Create a new Session using the given provider URI.
Class Method Details
.open(uri, &block) ⇒ Object
Public: Create a new Session using the given provider URI
uri - the String representing the provider to talk to
Yields the created Session. When the block returns, the session is closed
Examples
session = Qup.open( 'kestrel://localhost:22133' )
session = Qup.open( 'maildir:///tmp/qup' )
Returns a Session.
19 20 21 |
# File 'lib/qup.rb', line 19 def self.open( uri, &block ) Qup::Session.open( uri, &block ) end |