lib/amqp/client/frames.rb in amqp-client-1.0.2 vs lib/amqp/client/frames.rb in amqp-client-1.1.0

- old
+ new

@@ -8,13 +8,11 @@ # Generate binary data for different frames # Each frame type implemented as a method # Having a class for each frame type is more expensive in terms of CPU and memory # @api private module FrameBytes - module_function - - def connection_start_ok(response, properties) + def self.connection_start_ok(response, properties) prop_tbl = Table.encode(properties) [ 1, # type: method 0, # channel id 2 + 2 + 4 + prop_tbl.bytesize + 6 + 4 + response.bytesize + 1, # frame size @@ -26,11 +24,11 @@ 0, "", # locale 206 # frame end ].pack("C S> L> S> S> L>a* Ca* L>a* Ca* C") end - def connection_tune_ok(channel_max, frame_max, heartbeat) + def self.connection_tune_ok(channel_max, frame_max, heartbeat) [ 1, # type: method 0, # channel id 12, # frame size 10, # class: connection @@ -40,11 +38,11 @@ heartbeat, 206 # frame end ].pack("CS>L>S>S>S>L>S>C") end - def connection_open(vhost) + def self.connection_open(vhost) [ 1, # type: method 0, # channel id 2 + 2 + 1 + vhost.bytesize + 1 + 1, # frame_size 10, # class: connection @@ -54,11 +52,11 @@ 0, # reserved2 206 # frame end ].pack("C S> L> S> S> Ca* CCC") end - def connection_close(code, reason) + def self.connection_close(code, reason) frame_size = 2 + 2 + 2 + 1 + reason.bytesize + 2 + 2 [ 1, # type: method 0, # channel id frame_size, # frame size @@ -70,22 +68,22 @@ 0, # error method id 206 # frame end ].pack("C S> L> S> S> S> Ca* S> S> C") end - def connection_close_ok + def self.connection_close_ok [ 1, # type: method 0, # channel id 4, # frame size 10, # class: connection 51, # method: close-ok 206 # frame end ].pack("C S> L> S> S> C") end - def channel_open(id) + def self.channel_open(id) [ 1, # type: method id, # channel id 5, # frame size 20, # class: channel @@ -93,11 +91,11 @@ 0, # reserved1 206 # frame end ].pack("C S> L> S> S> C C") end - def channel_close(id, reason, code) + def self.channel_close(id, reason, code) frame_size = 2 + 2 + 2 + 1 + reason.bytesize + 2 + 2 [ 1, # type: method id, # channel id frame_size, # frame size @@ -109,22 +107,22 @@ 0, # error method id 206 # frame end ].pack("C S> L> S> S> S> Ca* S> S> C") end - def channel_close_ok(id) + def self.channel_close_ok(id) [ 1, # type: method id, # channel id 4, # frame size 20, # class: channel 41, # method: close-ok 206 # frame end ].pack("C S> L> S> S> C") end - def exchange_declare(id, name, type, passive, durable, auto_delete, internal, arguments) + def self.exchange_declare(id, name, type, passive, durable, auto_delete, internal, arguments) no_wait = false bits = 0 bits |= (1 << 0) if passive bits |= (1 << 1) if durable bits |= (1 << 2) if auto_delete @@ -145,11 +143,11 @@ tbl.bytesize, tbl, # arguments 206 # frame end ].pack("C S> L> S> S> S> Ca* Ca* C L>a* C") end - def exchange_delete(id, name, if_unused, no_wait) + def self.exchange_delete(id, name, if_unused, no_wait) bits = 0 bits |= (1 << 0) if if_unused bits |= (1 << 1) if no_wait frame_size = 2 + 2 + 2 + 1 + name.bytesize + 1 [ @@ -163,11 +161,11 @@ bits, 206 # frame end ].pack("C S> L> S> S> S> Ca* C C") end - def exchange_bind(id, destination, source, binding_key, no_wait, arguments) + def self.exchange_bind(id, destination, source, binding_key, no_wait, arguments) tbl = Table.encode(arguments) frame_size = 2 + 2 + 2 + 1 + destination.bytesize + 1 + source.bytesize + 1 + binding_key.bytesize + 1 + 4 + tbl.bytesize [ 1, # type: method @@ -183,11 +181,11 @@ tbl.bytesize, tbl, # arguments 206 # frame end ].pack("C S> L> S> S> S> Ca* Ca* Ca* C L>a* C") end - def exchange_unbind(id, destination, source, binding_key, no_wait, arguments) + def self.exchange_unbind(id, destination, source, binding_key, no_wait, arguments) tbl = Table.encode(arguments) frame_size = 2 + 2 + 2 + 1 + destination.bytesize + 1 + source.bytesize + 1 + binding_key.bytesize + 1 + 4 + tbl.bytesize [ 1, # type: method @@ -203,11 +201,11 @@ tbl.bytesize, tbl, # arguments 206 # frame end ].pack("C S> L> S> S> S> Ca* Ca* Ca* C L>a* C") end - def queue_declare(id, name, passive, durable, exclusive, auto_delete, arguments) + def self.queue_declare(id, name, passive, durable, exclusive, auto_delete, arguments) no_wait = false bits = 0 bits |= (1 << 0) if passive bits |= (1 << 1) if durable bits |= (1 << 2) if exclusive @@ -227,11 +225,11 @@ tbl.bytesize, tbl, # arguments 206 # frame end ].pack("C S> L> S> S> S> Ca* C L>a* C") end - def queue_delete(id, name, if_unused, if_empty, no_wait) + def self.queue_delete(id, name, if_unused, if_empty, no_wait) bits = 0 bits |= (1 << 0) if if_unused bits |= (1 << 1) if if_empty bits |= (1 << 2) if no_wait frame_size = 2 + 2 + 2 + 1 + name.bytesize + 1 @@ -246,11 +244,11 @@ bits, 206 # frame end ].pack("C S> L> S> S> S> Ca* C C") end - def queue_bind(id, queue, exchange, binding_key, no_wait, arguments) + def self.queue_bind(id, queue, exchange, binding_key, no_wait, arguments) tbl = Table.encode(arguments) frame_size = 2 + 2 + 2 + 1 + queue.bytesize + 1 + exchange.bytesize + 1 + binding_key.bytesize + 1 + 4 + tbl.bytesize [ 1, # type: method @@ -266,11 +264,11 @@ tbl.bytesize, tbl, # arguments 206 # frame end ].pack("C S> L> S> S> S> Ca* Ca* Ca* C L>a* C") end - def queue_unbind(id, queue, exchange, binding_key, arguments) + def self.queue_unbind(id, queue, exchange, binding_key, arguments) tbl = Table.encode(arguments) frame_size = 2 + 2 + 2 + 1 + queue.bytesize + 1 + exchange.bytesize + 1 + binding_key.bytesize + 4 + tbl.bytesize [ 1, # type: method @@ -285,11 +283,11 @@ tbl.bytesize, tbl, # arguments 206 # frame end ].pack("C S> L> S> S> S> Ca* Ca* Ca* L>a* C") end - def queue_purge(id, queue, no_wait) + def self.queue_purge(id, queue, no_wait) frame_size = 2 + 2 + 2 + 1 + queue.bytesize + 1 [ 1, # type: method id, # channel id frame_size, # frame size @@ -300,11 +298,11 @@ no_wait ? 1 : 0, 206 # frame end ].pack("C S> L> S> S> S> Ca* C C") end - def basic_get(id, queue, no_ack) + def self.basic_get(id, queue, no_ack) frame_size = 2 + 2 + 2 + 1 + queue.bytesize + 1 [ 1, # type: method id, # channel id frame_size, # frame size @@ -315,11 +313,11 @@ no_ack ? 1 : 0, 206 # frame end ].pack("C S> L> S> S> S> Ca* C C") end - def basic_publish(id, exchange, routing_key, mandatory) + def self.basic_publish(id, exchange, routing_key, mandatory) frame_size = 2 + 2 + 2 + 1 + exchange.bytesize + 1 + routing_key.bytesize + 1 [ 1, # type: method id, # channel id frame_size, # frame size @@ -331,11 +329,11 @@ mandatory ? 1 : 0, # bits, mandatory/immediate 206 # frame end ].pack("C S> L> S> S> S> Ca* Ca* C C") end - def header(id, body_size, properties) + def self.header(id, body_size, properties) props = Properties.new(**properties).encode frame_size = 2 + 2 + 8 + props.bytesize [ 2, # type: header id, # channel id @@ -346,21 +344,21 @@ props, # properties 206 # frame end ].pack("C S> L> S> S> Q> a* C") end - def body(id, body_part) + def self.body(id, body_part) [ 3, # type: body id, # channel id body_part.bytesize, # frame size body_part, 206 # frame end ].pack("C S> L> a* C") end - def basic_consume(id, queue, tag, no_ack, exclusive, arguments) + def self.basic_consume(id, queue, tag, no_ack, exclusive, arguments) no_local = false no_wait = false bits = 0 bits |= (1 << 0) if no_local bits |= (1 << 1) if no_ack @@ -381,11 +379,11 @@ tbl.bytesize, tbl, # arguments 206 # frame end ].pack("C S> L> S> S> S> Ca* Ca* C L>a* C") end - def basic_cancel(id, consumer_tag, no_wait: false) + def self.basic_cancel(id, consumer_tag, no_wait: false) frame_size = 2 + 2 + 1 + consumer_tag.bytesize + 1 [ 1, # type: method id, # channel id frame_size, # frame size @@ -395,11 +393,11 @@ no_wait ? 1 : 0, 206 # frame end ].pack("C S> L> S> S> Ca* C C") end - def basic_cancel_ok(id, consumer_tag) + def self.basic_cancel_ok(id, consumer_tag) frame_size = 2 + 2 + 1 + consumer_tag.bytesize + 1 [ 1, # type: method id, # channel id frame_size, # frame size @@ -408,11 +406,11 @@ consumer_tag.bytesize, consumer_tag, 206 # frame end ].pack("C S> L> S> S> Ca* C") end - def basic_ack(id, delivery_tag, multiple) + def self.basic_ack(id, delivery_tag, multiple) frame_size = 2 + 2 + 8 + 1 [ 1, # type: method id, # channel id frame_size, # frame size @@ -422,11 +420,11 @@ multiple ? 1 : 0, 206 # frame end ].pack("C S> L> S> S> Q> C C") end - def basic_nack(id, delivery_tag, multiple, requeue) + def self.basic_nack(id, delivery_tag, multiple, requeue) bits = 0 bits |= (1 << 0) if multiple bits |= (1 << 1) if requeue frame_size = 2 + 2 + 8 + 1 [ @@ -439,11 +437,11 @@ bits, 206 # frame end ].pack("C S> L> S> S> Q> C C") end - def basic_reject(id, delivery_tag, requeue) + def self.basic_reject(id, delivery_tag, requeue) frame_size = 2 + 2 + 8 + 1 [ 1, # type: method id, # channel id frame_size, # frame size @@ -453,11 +451,11 @@ requeue ? 1 : 0, 206 # frame end ].pack("C S> L> S> S> Q> C C") end - def basic_qos(id, prefetch_size, prefetch_count, global) + def self.basic_qos(id, prefetch_size, prefetch_count, global) frame_size = 2 + 2 + 4 + 2 + 1 [ 1, # type: method id, # channel id frame_size, # frame size @@ -468,11 +466,11 @@ global ? 1 : 0, 206 # frame end ].pack("C S> L> S> S> L> S> C C") end - def basic_recover(id, requeue) + def self.basic_recover(id, requeue) frame_size = 2 + 2 + 1 [ 1, # type: method id, # channel id frame_size, # frame size @@ -481,11 +479,11 @@ requeue ? 1 : 0, 206 # frame end ].pack("C S> L> S> S> C C") end - def confirm_select(id, no_wait) + def self.confirm_select(id, no_wait) [ 1, # type: method id, # channel id 5, # frame size 85, # class: confirm @@ -493,11 +491,11 @@ no_wait ? 1 : 0, 206 # frame end ].pack("C S> L> S> S> C C") end - def tx_select(id) + def self.tx_select(id) frame_size = 2 + 2 [ 1, # type: method id, # channel id frame_size, # frame size @@ -505,11 +503,11 @@ 10, # method: select 206 # frame end ].pack("C S> L> S> S> C") end - def tx_commit(id) + def self.tx_commit(id) frame_size = 2 + 2 [ 1, # type: method id, # channel id frame_size, # frame size @@ -517,10 +515,10 @@ 20, # method: commit 206 # frame end ].pack("C S> L> S> S> C") end - def tx_rollback(id) + def self.tx_rollback(id) frame_size = 2 + 2 [ 1, # type: method id, # channel id frame_size, # frame size