Class: Packageiq::Transport::Rabbitmq
- Inherits:
-
Object
- Object
- Packageiq::Transport::Rabbitmq
- Defined in:
- lib/packageiq/transport/rabbitmq.rb
Overview
rabbitmq transport
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#host ⇒ Object
Returns the value of attribute host.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#port ⇒ Object
Returns the value of attribute port.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#tls ⇒ Object
Returns the value of attribute tls.
-
#tls_ca_certificates ⇒ Object
Returns the value of attribute tls_ca_certificates.
-
#tls_cert ⇒ Object
Returns the value of attribute tls_cert.
-
#tls_key ⇒ Object
Returns the value of attribute tls_key.
-
#user ⇒ Object
Returns the value of attribute user.
-
#vhost ⇒ Object
Returns the value of attribute vhost.
Class Method Summary collapse
-
.serialize(message) ⇒ Object
serialize message.
Instance Method Summary collapse
-
#close_channel ⇒ Object
close rabbitmq channel.
-
#create_channel ⇒ Object
create rabbitmq channel.
-
#create_queue(name, opts = {}) ⇒ Object
create rabbitmq queue.
-
#initialize(args = {}) ⇒ Rabbitmq
constructor
A new instance of Rabbitmq.
-
#queue_exists?(name) ⇒ Boolean
check if queue exists returns boolean.
-
#start ⇒ Object
initialize bunny instance and start connection.
Constructor Details
#initialize(args = {}) ⇒ Rabbitmq
Returns a new instance of Rabbitmq.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 12 def initialize(args = {}) @host = args[:host] || '127.0.0.1' @port = args[:port] || 5672 @tls = args[:tls] || false @tls_cert = args[:tls_cert] || '' @tls_key = args[:tls_key] || '' @tls_ca_certificates = args[:tls_ca_certificates] || [] @vhost = args[:vhost] || '/' @user = args[:user] || 'guest' @pass = args[:pass] || 'guest' end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
41 42 43 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 41 def channel @channel end |
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
29 30 31 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 29 def conn @conn end |
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 8 def host @host end |
#pass ⇒ Object
Returns the value of attribute pass.
8 9 10 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 8 def pass @pass end |
#port ⇒ Object
Returns the value of attribute port.
8 9 10 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 8 def port @port end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
53 54 55 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 53 def queue @queue end |
#tls ⇒ Object
Returns the value of attribute tls.
8 9 10 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 8 def tls @tls end |
#tls_ca_certificates ⇒ Object
Returns the value of attribute tls_ca_certificates.
8 9 10 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 8 def tls_ca_certificates @tls_ca_certificates end |
#tls_cert ⇒ Object
Returns the value of attribute tls_cert.
8 9 10 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 8 def tls_cert @tls_cert end |
#tls_key ⇒ Object
Returns the value of attribute tls_key.
8 9 10 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 8 def tls_key @tls_key end |
#user ⇒ Object
Returns the value of attribute user.
8 9 10 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 8 def user @user end |
#vhost ⇒ Object
Returns the value of attribute vhost.
8 9 10 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 8 def vhost @vhost end |
Class Method Details
.serialize(message) ⇒ Object
serialize message
25 26 27 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 25 def self.serialize() .to_json end |
Instance Method Details
#close_channel ⇒ Object
close rabbitmq channel
49 50 51 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 49 def close_channel @channel.close_channel end |
#create_channel ⇒ Object
create rabbitmq channel
44 45 46 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 44 def create_channel @channel = conn.create_channel end |
#create_queue(name, opts = {}) ⇒ Object
create rabbitmq queue
56 57 58 59 60 61 62 63 64 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 56 def create_queue(name, opts = {}) durable = opts[:durable] || false auto_delete = opts[:auto_delete] || false exclusive = opts[:exclusive] || false @queue = channel.queue(name, durable: durable, auto_delete: auto_delete, exclusive: exclusive) end |
#queue_exists?(name) ⇒ Boolean
check if queue exists returns boolean
68 69 70 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 68 def queue_exists?(name) conn.queue_exists?(name) end |
#start ⇒ Object
initialize bunny instance and start connection
32 33 34 35 36 37 38 39 |
# File 'lib/packageiq/transport/rabbitmq.rb', line 32 def start @conn = Bunny.new(host: host, port: port, tls: tls, tls_cert: tls_cert, tls_key: tls_key, tls_ca_certificates: tls_ca_certificates, vhost: vhost, user: user, pass: pass) @conn.start end |