Class: QRPC::Locator::EMJackLocator
- Inherits:
-
Object
- Object
- QRPC::Locator::EMJackLocator
- Defined in:
- lib/qrpc/locator/em-jack.rb
Overview
Locator for ‘em-jack’ (so EventMachine Beanstalk implementation) queue type.
Constant Summary collapse
- PARSER =
Parser.
/^(.+)@(.+)(?:\:(\d+))?$/
- DEFAULT_PORT =
Default port.
11300
Instance Attribute Summary collapse
-
#host ⇒ String
Contains host.
-
#port ⇒ Integer
Contains port.
-
#queue_name ⇒ String
Contains queue name.
Class Method Summary collapse
-
.parse(string) ⇒ QRPC::Locator
Parses the locator.
Instance Method Summary collapse
-
#initialize(queue_name, host = "localhost", port = 11300) ⇒ EMJackLocator
constructor
Constructor.
-
#input_queue ⇒ UnifiedQueues::Multi
Returns universal queue interface for input queue.
-
#output_queue ⇒ UnifiedQueues::Multi
Returns universal queue interface for output queue.
-
#to_s ⇒ String
Converts back to string.
Constructor Details
#initialize(queue_name, host = "localhost", port = 11300) ⇒ EMJackLocator
Constructor.
88 89 90 91 92 |
# File 'lib/qrpc/locator/em-jack.rb', line 88 def initialize(queue_name, host = "localhost", port = 11300) @queue_name = queue_name.to_s @host = host @port = port end |
Instance Attribute Details
#host ⇒ String
Contains host.
57 58 59 |
# File 'lib/qrpc/locator/em-jack.rb', line 57 def host @host end |
#port ⇒ Integer
Contains port.
65 66 67 |
# File 'lib/qrpc/locator/em-jack.rb', line 65 def port @port end |
#queue_name ⇒ String
Contains queue name.
49 50 51 |
# File 'lib/qrpc/locator/em-jack.rb', line 49 def queue_name @queue_name end |
Class Method Details
.parse(string) ⇒ QRPC::Locator
Parses the locator. Excpects form <queue>@<host>:<port>. Port is optional.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/qrpc/locator/em-jack.rb', line 102 def self.parse(string) match = string.match(self::PARSER) queue = match.first host = match.second if match.length == 3 port = match.third else port = self::DEFAULT_PORT end port = port.to_i ## return self::new(queue, host, port); end |
Instance Method Details
#input_queue ⇒ UnifiedQueues::Multi
Returns universal queue interface for input queue.
135 136 137 138 139 140 141 |
# File 'lib/qrpc/locator/em-jack.rb', line 135 def input_queue if @input_queue.nil? @input_queue = UnifiedQueues::Multi::new EMJack::Connection, :host => @host, :port => @port else @input_queue end end |
#output_queue ⇒ UnifiedQueues::Multi
Returns universal queue interface for output queue.
148 149 150 151 152 153 154 |
# File 'lib/qrpc/locator/em-jack.rb', line 148 def output_queue if @output_queue.nil? @output_queue = UnifiedQueues::Multi::new EMJack::Connection, :host => @host, :port => @port else @output_queue end end |
#to_s ⇒ String
Converts back to string.
126 127 128 |
# File 'lib/qrpc/locator/em-jack.rb', line 126 def to_s @queue_name + "@" + @host + ":" + @port.to_s end |