Class: Qup::Adapter::Kestrel

Inherits:
Qup::Adapter show all
Defined in:
lib/qup/adapter/kestrel.rb,
lib/qup/adapter/kestrel/queue.rb,
lib/qup/adapter/kestrel/topic.rb,
lib/qup/adapter/kestrel/destination.rb

Overview

Internal: The backing adapter for Qup that uses Kestrel as the messaging infrastructure

Defined Under Namespace

Classes: Destination, Queue, Topic

Instance Method Summary collapse

Methods inherited from Qup::Adapter

register

Constructor Details

#initialize(uri, options = {}) ⇒ Kestrel

Internal: Create a new Kestrel Adapter

uri - the URI instance for this adapter to use



15
16
17
18
19
20
21
22
23
# File 'lib/qup/adapter/kestrel.rb', line 15

def initialize( uri, options = {} )
  @uri        = uri
  @host       = @uri.host
  @port       = @uri.port.to_i
  @client_options = options.merge( :host => @host, :port => @port )
  @client     = KJess::Client.new( @client_options )
  @client.ping
  @closed     = false
end

Instance Method Details

#closeObject

Internal: Close the Kestrel adapter

Return nothing



46
47
48
# File 'lib/qup/adapter/kestrel.rb', line 46

def close
  @client.disconnect
end

#closed?Boolean

Internal: Is the Kestrel Adapter closed

Returns true or false

Returns:

  • (Boolean)


53
54
55
# File 'lib/qup/adapter/kestrel.rb', line 53

def closed?
  not @client.connected?
end

#queue(name) ⇒ Object

Internal: Create a new Queue from this Adapter

name - the String name of the Queue

Returns a Qup::Queue



30
31
32
# File 'lib/qup/adapter/kestrel.rb', line 30

def queue( name )
  Qup::Adapter::Kestrel::Queue.new( @client, name )
end

#topic(name) ⇒ Object

Internal: Create a new Topic from this Adapter

name - the name of this Topic

Returns a Qup::Topic



39
40
41
# File 'lib/qup/adapter/kestrel.rb', line 39

def topic( name )
  Qup::Adapter::Kestrel::Topic.new( @client, name )
end