amqp-client 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,264 @@
1
+ # TypeProf 0.15.3
2
+
3
+ # Classes
4
+ module AMQP
5
+ class Client
6
+ VERSION: String
7
+ @uri: String
8
+ @options: Hash[Symbol, (String | Integer | bool)]
9
+ @queues: Hash[String, Queue]
10
+ @exchanges: Hash[String, Exchange]
11
+ @subscriptions: Set[[String, bool, Integer, Integer, Hash[Symbol, untyped], nil]]
12
+ @connq: Thread::SizedQueue
13
+ @stopped: bool
14
+
15
+ def initialize: (?String uri, **untyped) -> void
16
+ def connect: (?read_loop_thread: bool) -> Connection
17
+ def start: -> Client
18
+ def stop: -> nil
19
+ def queue: (String name, ?durable: bool, ?auto_delete: bool, ?arguments: Hash[Symbol | String, (String | Integer | bool)]) -> Queue
20
+ def exchange: (String name, String `type`, ?durable: bool, ?auto_delete: bool, ?internal: bool, ?arguments: Hash[Symbol | String, untyped]) -> Exchange
21
+ def publish: (String body, String exchange, String routing_key, **untyped) -> bool
22
+ def publish_and_forget: (String body, String exchange, String routing_key, **untyped) -> nil
23
+ def wait_for_confirms: -> bool
24
+ def subscribe: (String queue, ?no_ack: bool, ?prefetch: Integer, ?worker_threads: Integer, ?arguments: Hash[Symbol | String, untyped]) { (Message) -> void } -> [String, Array[Thread]]?
25
+ def bind: (String queue, String exchange, String binding_key, ?arguments: Hash[Symbol | String, untyped]) -> nil
26
+ def unbind: (String queue, String exchange, String binding_key, ?arguments: Hash[Symbol | String, untyped]) -> nil
27
+ def purge: (String queue) -> nil
28
+ def delete_queue: (String name, ?if_unused: bool, ?if_empty: bool) -> Integer?
29
+ def exchange_bind: (String destination, String source, String binding_key, ?arguments: Hash[Symbol | String, untyped]) -> nil
30
+ def exchange_unbind: (String destination, String source, String binding_key, ?arguments: Hash[Symbol | String, untyped]) -> nil
31
+ def delete_exchange: (String name) -> nil
32
+ def with_connection: { (Connection) -> void } -> void
33
+
34
+ module Table
35
+ def self.encode: (Hash[Symbol | String, untyped] hash) -> String
36
+ def self.decode: (String bytes) -> Hash[String, untyped]
37
+ end
38
+
39
+ class Properties
40
+ attr_accessor content_type(): String?
41
+ attr_accessor content_encoding(): String?
42
+ attr_accessor headers(): Hash[String | Symbol, untyped]?
43
+ attr_accessor delivery_mode(): Integer?
44
+ attr_accessor priority(): Integer?
45
+ attr_accessor correlation_id(): String?
46
+ attr_accessor reply_to(): String?
47
+ attr_accessor expiration(): (Integer | String)?
48
+ attr_accessor message_id(): String?
49
+ attr_accessor timestamp(): Time?
50
+ attr_accessor type(): String?
51
+ attr_accessor user_id(): String?
52
+ attr_accessor app_id(): String?
53
+ end
54
+
55
+ module FrameBytes
56
+ def self.connection_start_ok: (String response, Hash[untyped, untyped] properties) -> String
57
+ def self.connection_tune_ok: ((Float | Integer | String)? channel_max, (Float | Integer | String)? frame_max, (Float | Integer | String)? heartbeat) -> String
58
+ def self.connection_open: (String vhost) -> String
59
+ def self.connection_close: (Integer code, String reason) -> String
60
+ def self.connection_close_ok: -> String
61
+ def self.channel_open: (Integer id) -> String
62
+ def self.channel_close: (Integer id, String reason, Integer code) -> String
63
+ def self.channel_close_ok: ((Float | Integer | String)? id) -> String
64
+ def self.exchange_declare: (Integer id, untyped name, untyped `type`, bool passive, bool durable, bool auto_delete, bool internal, Hash[untyped, untyped] arguments) -> String
65
+ def self.exchange_delete: (Integer id, untyped name, bool if_unused, bool no_wait) -> String
66
+ def self.exchange_bind: (Integer id, untyped destination, untyped source, untyped binding_key, bool no_wait, Hash[untyped, untyped] arguments) -> String
67
+ def self.exchange_unbind: (Integer id, untyped destination, untyped source, untyped binding_key, bool no_wait, Hash[untyped, untyped] arguments) -> String
68
+ def self.queue_declare: (Integer id, String name, bool passive, bool durable, bool exclusive, bool auto_delete, Hash[untyped, untyped] arguments) -> String
69
+ def self.queue_delete: (Integer id, untyped name, bool if_unused, bool if_empty, bool no_wait) -> String
70
+ def self.queue_bind: (Integer id, untyped queue, untyped exchange, untyped binding_key, bool no_wait, Hash[untyped, untyped] arguments) -> String
71
+ def self.queue_unbind: (Integer id, untyped queue, untyped exchange, untyped binding_key, Hash[untyped, untyped] arguments) -> String
72
+ def self.queue_purge: (Integer id, untyped queue, bool no_wait) -> String
73
+ def self.basic_get: (Integer id, untyped queue, bool no_ack) -> String
74
+ def self.basic_publish: (Integer id, untyped exchange, untyped routing_key, bool mandatory) -> String
75
+ def self.header: (Integer id, untyped body_size, Hash[(Symbol | String), untyped] properties) -> String
76
+ def self.body: (Integer id, untyped body_part) -> String
77
+ def self.basic_consume: (Integer id, String queue, String? tag, bool? no_ack, bool? exclusive, Hash[untyped, untyped]? arguments) -> String
78
+ def self.basic_cancel: (Integer id, untyped consumer_tag, ?no_wait: bool) -> String
79
+ def self.basic_cancel_ok: (Integer id, String consumer_tag) -> String
80
+ def self.basic_ack: (Integer id, untyped delivery_tag, bool multiple) -> String
81
+ def self.basic_nack: (Integer id, untyped delivery_tag, bool multiple, bool requeue) -> String
82
+ def self.basic_reject: (Integer id, untyped delivery_tag, bool requeue) -> String
83
+ def self.basic_qos: (Integer id, Integer? prefetch_size, Integer? prefetch_count, bool? global) -> String
84
+ def self.basic_recover: (Integer id, untyped requeue) -> String
85
+ def self.confirm_select: (Integer id, bool no_wait) -> String
86
+ def self.tx_select: (Integer id) -> String
87
+ def self.tx_commit: (Integer id) -> String
88
+ def self.tx_rollback: (Integer id) -> String
89
+ end
90
+
91
+ class Message
92
+ attr_reader channel(): Connection::Channel
93
+ attr_reader delivery_tag(): Integer
94
+ attr_reader exchange(): String
95
+ attr_reader routing_key(): String
96
+ attr_reader redelivered(): bool
97
+ attr_reader consumer_tag(): String?
98
+ attr_accessor properties(): Properties
99
+ attr_accessor body(): String
100
+ end
101
+
102
+ class ReturnMessage
103
+ attr_reader reply_code(): Integer
104
+ attr_reader reply_text(): String
105
+ attr_reader exchange(): String
106
+ attr_reader routing_key(): String
107
+ attr_accessor properties(): Properties
108
+ attr_accessor body(): String
109
+ end
110
+
111
+ class Connection
112
+ CLIENT_PROPERTIES: Hash[Symbol | String, untyped]
113
+ @socket: (IO | untyped)
114
+ @channel_max: Integer
115
+ @heartbeat: Integer
116
+ @channels: Hash[Integer, Channel]
117
+ @closed: Array[untyped]?
118
+ @replies: Thread::Queue
119
+ @write_lock: Thread::Mutex
120
+ @blocked: String?
121
+ @id: Integer
122
+
123
+ def initialize: (?String uri, ?read_loop_thread: bool, **untyped) -> void
124
+ def self.connect: (?String uri, ?read_loop_thread: bool, **untyped) -> Connection
125
+ attr_reader frame_max: Integer
126
+ def inspect: -> String
127
+ def channel: (?Integer? id) -> Channel
128
+ def with_channel: { (Channel) -> void } -> void
129
+ def close: (?reason: String, ?code: Integer) -> nil
130
+ def closed?: -> bool
131
+ def write_bytes: (*String bytes) -> Integer
132
+ def read_loop: -> nil
133
+
134
+ private
135
+ def parse_frame: (Integer `type`, Integer channel_id, String buf) -> bool
136
+ def expect: (:close_ok expected_frame_type) -> untyped
137
+ def open_socket: (String host, Integer port, bool tls, Hash[Symbol, untyped] options) -> (IO | untyped)
138
+ def establish: ((IO | untyped) socket, String user, String password, String vhost, Hash[Symbol, untyped] options) -> [Integer, Integer, Integer]
139
+ def enable_tcp_keepalive: ((IO | untyped) socket) -> void
140
+ def port_from_env: -> Integer?
141
+
142
+ class Channel
143
+ @connection: Connection
144
+ @replies: Thread::Queue
145
+ @consumers: Hash[String, Thread::Queue]
146
+ @closed: Array[(:channel | :connection | Integer | String)]?
147
+ @open: bool
148
+ @on_return: nil
149
+ @confirm: Integer?
150
+ @unconfirmed: Thread::Queue
151
+ @unconfirmed_empty: Thread::Queue
152
+ @basic_gets: Thread::Queue
153
+ @next_msg: (Message | ReturnMessage)?
154
+ @next_body: StringIO?
155
+ @next_body_size: (Float | Integer | String)?
156
+
157
+ def initialize: (Connection connection, Integer? id) -> void
158
+ def inspect: -> String
159
+ attr_reader id: Integer?
160
+ def open: -> Channel
161
+ def close: (?reason: String, ?code: Integer) -> nil
162
+ def closed!: (:channel | :connection level, (Float | Integer | String)? code, String reason, (Float | Integer | String)? classid, (Float | Integer | String)? methodid) -> nil
163
+ def on_return: { (ReturnMessage) -> void } -> void
164
+ def exchange_declare: (String name, String `type`, ?passive: bool, ?durable: bool, ?auto_delete: bool, ?internal: bool, ?arguments: Hash[untyped, untyped]) -> nil
165
+ def exchange_delete: (String name, ?if_unused: bool, ?no_wait: bool) -> nil
166
+ def exchange_bind: (String destination, String source, String binding_key, ?arguments: Hash[untyped, untyped]) -> nil
167
+ def exchange_unbind: (String destination, String source, String binding_key, ?arguments: Hash[untyped, untyped]) -> nil
168
+ def queue_declare: (?String name, ?passive: bool, ?durable: bool, ?exclusive: bool, ?auto_delete: bool, ?arguments: Hash[untyped, untyped]) -> QueueOk
169
+ def queue_delete: (String name, ?if_unused: bool, ?if_empty: bool, ?no_wait: bool) -> Integer?
170
+ def queue_bind: (String name, String exchange, String binding_key, ?arguments: Hash[untyped, untyped]) -> nil
171
+ def queue_purge: (String name, ?no_wait: bool) -> nil
172
+ def queue_unbind: (String name, String exchange, String binding_key, ?arguments: Hash[untyped, untyped]) -> nil
173
+ def basic_get: (String queue_name, ?no_ack: bool) -> Message?
174
+ def basic_publish: (String body, String exchange, String routing_key, **untyped) -> nil
175
+ def basic_publish_confirm: (String body, String exchange, String routing_key, **untyped) -> bool
176
+ def basic_consume: (String queue, ?tag: String, ?no_ack: bool?, ?exclusive: bool, ?arguments: Hash[untyped, untyped]?, ?worker_threads: Integer?) { (Message) -> void } -> [String, Array[Thread]]?
177
+ def basic_cancel: (String consumer_tag, ?no_wait: bool) -> nil
178
+ def basic_qos: (Integer prefetch_count, ?prefetch_size: Integer, ?global: bool) -> nil
179
+ def basic_ack: (Integer delivery_tag, ?multiple: bool) -> nil
180
+ def basic_nack: (Integer delivery_tag, ?multiple: bool, ?requeue: bool) -> nil
181
+ def basic_reject: (Integer delivery_tag, ?requeue: bool) -> nil
182
+ def basic_recover: (?requeue: bool) -> nil
183
+ def confirm_select: (?no_wait: bool) -> nil
184
+ def wait_for_confirms: -> bool
185
+ def tx_select: -> nil
186
+ def tx_commit: -> nil
187
+ def tx_rollback: -> nil
188
+ def reply: (Array[untyped] args) -> void
189
+ def confirm: (Array[(:ack | :nack | Integer | bool)] args) -> nil
190
+ def message_returned: ((Float | Integer | String)? reply_code, String reply_text, String exchange, String routing_key) -> ReturnMessage
191
+ def message_delivered: (String? consumer_tag, (Float | Integer | String)? delivery_tag, bool redelivered, String exchange, String routing_key) -> Message
192
+ def basic_get_empty: -> void
193
+ def header_delivered: (Integer body_size, Properties properties) -> void
194
+ def body_delivered: (String body_part) -> void
195
+ def close_consumer: (String tag) -> nil
196
+
197
+ private
198
+ def next_message_finished!: -> void
199
+ def write_bytes: (*String bytes) -> Integer
200
+ def expect: (Symbol expected_frame_type) -> Array[untyped]
201
+
202
+ class QueueOk < Struct[untyped]
203
+ attr_accessor queue_name(): String
204
+ attr_accessor message_count(): Integer
205
+ attr_accessor consumer_count(): Integer
206
+ end
207
+ end
208
+ end
209
+
210
+ class Error < StandardError
211
+ class UnexpectedFrame < Error
212
+ def initialize: (Symbol expected, Symbol actual) -> void
213
+ end
214
+
215
+ class UnexpectedFrameEnd < Error
216
+ def initialize: (untyped actual) -> void
217
+ end
218
+
219
+ class UnsupportedFrameType < Error
220
+ def initialize: (untyped `type`) -> void
221
+ end
222
+
223
+ class UnsupportedMethodFrame < Error
224
+ def initialize: (Integer class_id, Integer method_id) -> void
225
+ end
226
+
227
+ class Closed < Error
228
+ def self.new: (Integer id, (:channel | :connection) level, Integer code, String reason, ?Integer classid, ?Integer methodid) -> (ChannelClosed | ConnectionClosed)
229
+ end
230
+
231
+ class ChannelClosed < Error
232
+ def initialize: (Integer id, Integer code, String reason, ?Integer classid, ?Integer methodid) -> void
233
+ end
234
+
235
+ class ConnectionClosed < Error
236
+ def initialize: (Integer code, String reason, ?Integer classid, ?Integer methodid) -> void
237
+ end
238
+ end
239
+
240
+ class Exchange
241
+ @client: Client
242
+ @name: String
243
+
244
+ def initialize: (Client client, String name) -> void
245
+ def publish: (String body, String routing_key, **untyped) -> Exchange
246
+ def bind: (String exchange, String binding_key, ?arguments: Hash[String | Symbol, untyped]) -> Exchange
247
+ def unbind: (String exchange, String binding_key, ?arguments: Hash[String | Symbol, untyped]) -> Exchange
248
+ def delete: -> nil
249
+ end
250
+
251
+ class Queue
252
+ @client: Client
253
+ @name: String
254
+
255
+ def initialize: (Client client, String name) -> void
256
+ def publish: (String body, **untyped) -> Queue
257
+ def subscribe: (?no_ack: bool, ?prefetch: Integer, ?worker_threads: Integer, ?arguments: Hash[String | Symbol, untyped]) { (Message) -> void } -> Queue
258
+ def bind: (String exchange, String binding_key, ?arguments: Hash[String | Symbol, untyped]) -> Queue
259
+ def unbind: (String exchange, String binding_key, ?arguments: Hash[String | Symbol, untyped]) -> Queue
260
+ def purge: -> Queue
261
+ def delete: -> nil
262
+ end
263
+ end
264
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amqp-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Hörberg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-27 00:00:00.000000000 Z
11
+ date: 2021-09-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Work in progress
14
14
  email:
@@ -17,10 +17,12 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".github/workflows/docs.yml"
20
21
  - ".github/workflows/main.yml"
21
22
  - ".gitignore"
22
23
  - ".rubocop.yml"
23
24
  - ".rubocop_todo.yml"
25
+ - ".yardopts"
24
26
  - CHANGELOG.md
25
27
  - Gemfile
26
28
  - LICENSE.txt
@@ -34,11 +36,14 @@ files:
34
36
  - lib/amqp/client/channel.rb
35
37
  - lib/amqp/client/connection.rb
36
38
  - lib/amqp/client/errors.rb
37
- - lib/amqp/client/frames.rb
39
+ - lib/amqp/client/exchange.rb
40
+ - lib/amqp/client/frame_bytes.rb
38
41
  - lib/amqp/client/message.rb
39
42
  - lib/amqp/client/properties.rb
43
+ - lib/amqp/client/queue.rb
40
44
  - lib/amqp/client/table.rb
41
45
  - lib/amqp/client/version.rb
46
+ - sig/amqp-client.rbs
42
47
  homepage: https://github.com/cloudamqp/amqp-client.rb
43
48
  licenses:
44
49
  - MIT
@@ -54,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
59
  requirements:
55
60
  - - ">="
56
61
  - !ruby/object:Gem::Version
57
- version: 2.5.0
62
+ version: 2.6.0
58
63
  required_rubygems_version: !ruby/object:Gem::Requirement
59
64
  requirements:
60
65
  - - ">="
@@ -1,531 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "./properties"
4
- require_relative "./table"
5
-
6
- module AMQP
7
- # Generate binary data for different frames
8
- # Each frame type implemented as a method
9
- # Having a class for each frame type is more expensive in terms of CPU and memory
10
- module FrameBytes
11
- module_function
12
-
13
- def connection_start_ok(response, properties)
14
- prop_tbl = Table.encode(properties)
15
- [
16
- 1, # type: method
17
- 0, # channel id
18
- 2 + 2 + 4 + prop_tbl.bytesize + 6 + 4 + response.bytesize + 1, # frame size
19
- 10, # class id
20
- 11, # method id
21
- prop_tbl.bytesize, prop_tbl, # client props
22
- 5, "PLAIN", # mechanism
23
- response.bytesize, response,
24
- 0, "", # locale
25
- 206 # frame end
26
- ].pack("C S> L> S> S> L>a* Ca* L>a* Ca* C")
27
- end
28
-
29
- def connection_tune_ok(channel_max, frame_max, heartbeat)
30
- [
31
- 1, # type: method
32
- 0, # channel id
33
- 12, # frame size
34
- 10, # class: connection
35
- 31, # method: tune-ok
36
- channel_max,
37
- frame_max,
38
- heartbeat,
39
- 206 # frame end
40
- ].pack("CS>L>S>S>S>L>S>C")
41
- end
42
-
43
- def connection_open(vhost)
44
- [
45
- 1, # type: method
46
- 0, # channel id
47
- 2 + 2 + 1 + vhost.bytesize + 1 + 1, # frame_size
48
- 10, # class: connection
49
- 40, # method: open
50
- vhost.bytesize, vhost,
51
- 0, # reserved1
52
- 0, # reserved2
53
- 206 # frame end
54
- ].pack("C S> L> S> S> Ca* CCC")
55
- end
56
-
57
- def connection_close(code, reason)
58
- frame_size = 2 + 2 + 2 + 1 + reason.bytesize + 2 + 2
59
- [
60
- 1, # type: method
61
- 0, # channel id
62
- frame_size, # frame size
63
- 10, # class: connection
64
- 50, # method: close
65
- code,
66
- reason.bytesize, reason,
67
- 0, # error class id
68
- 0, # error method id
69
- 206 # frame end
70
- ].pack("C S> L> S> S> S> Ca* S> S> C")
71
- end
72
-
73
- def connection_close_ok
74
- [
75
- 1, # type: method
76
- 0, # channel id
77
- 4, # frame size
78
- 10, # class: connection
79
- 51, # method: close-ok
80
- 206 # frame end
81
- ].pack("C S> L> S> S> C")
82
- end
83
-
84
- def channel_open(id)
85
- [
86
- 1, # type: method
87
- id, # channel id
88
- 5, # frame size
89
- 20, # class: channel
90
- 10, # method: open
91
- 0, # reserved1
92
- 206 # frame end
93
- ].pack("C S> L> S> S> C C")
94
- end
95
-
96
- def channel_close(id, reason, code)
97
- frame_size = 2 + 2 + 2 + 1 + reason.bytesize + 2 + 2
98
- [
99
- 1, # type: method
100
- id, # channel id
101
- frame_size, # frame size
102
- 20, # class: channel
103
- 40, # method: close
104
- code,
105
- reason.bytesize, reason,
106
- 0, # error class id
107
- 0, # error method id
108
- 206 # frame end
109
- ].pack("C S> L> S> S> S> Ca* S> S> C")
110
- end
111
-
112
- def channel_close_ok(id)
113
- [
114
- 1, # type: method
115
- id, # channel id
116
- 4, # frame size
117
- 20, # class: channel
118
- 41, # method: close-ok
119
- 206 # frame end
120
- ].pack("C S> L> S> S> C")
121
- end
122
-
123
- def exchange_declare(id, name, type, passive, durable, auto_delete, internal, arguments)
124
- no_wait = false
125
- bits = 0
126
- bits |= (1 << 0) if passive
127
- bits |= (1 << 1) if durable
128
- bits |= (1 << 2) if auto_delete
129
- bits |= (1 << 3) if internal
130
- bits |= (1 << 4) if no_wait
131
- tbl = Table.encode(arguments)
132
- frame_size = 2 + 2 + 2 + 1 + name.bytesize + 1 + type.bytesize + 1 + 4 + tbl.bytesize
133
- [
134
- 1, # type: method
135
- id, # channel id
136
- frame_size, # frame size
137
- 40, # class: exchange
138
- 10, # method: declare
139
- 0, # reserved1
140
- name.bytesize, name,
141
- type.bytesize, type,
142
- bits,
143
- tbl.bytesize, tbl, # arguments
144
- 206 # frame end
145
- ].pack("C S> L> S> S> S> Ca* Ca* C L>a* C")
146
- end
147
-
148
- def exchange_delete(id, name, if_unused, no_wait)
149
- bits = 0
150
- bits |= (1 << 0) if if_unused
151
- bits |= (1 << 1) if no_wait
152
- frame_size = 2 + 2 + 2 + 1 + name.bytesize + 1
153
- [
154
- 1, # type: method
155
- id, # channel id
156
- frame_size, # frame size
157
- 40, # class: exchange
158
- 20, # method: delete
159
- 0, # reserved1
160
- name.bytesize, name,
161
- bits,
162
- 206 # frame end
163
- ].pack("C S> L> S> S> S> Ca* C C")
164
- end
165
-
166
- def exchange_bind(id, destination, source, binding_key, no_wait, arguments)
167
- tbl = Table.encode(arguments)
168
- frame_size = 2 + 2 + 2 + 1 + destination.bytesize + 1 + source.bytesize + 1 +
169
- binding_key.bytesize + 1 + 4 + tbl.bytesize
170
- [
171
- 1, # type: method
172
- id, # channel id
173
- frame_size, # frame size
174
- 40, # class: exchange
175
- 30, # method: bind
176
- 0, # reserved1
177
- destination.bytesize, destination,
178
- source.bytesize, source,
179
- binding_key.bytesize, binding_key,
180
- no_wait ? 1 : 0,
181
- tbl.bytesize, tbl, # arguments
182
- 206 # frame end
183
- ].pack("C S> L> S> S> S> Ca* Ca* Ca* C L>a* C")
184
- end
185
-
186
- def exchange_unbind(id, destination, source, binding_key, no_wait, arguments)
187
- tbl = Table.encode(arguments)
188
- frame_size = 2 + 2 + 2 + 1 + destination.bytesize + 1 + source.bytesize + 1 +
189
- binding_key.bytesize + 1 + 4 + tbl.bytesize
190
- [
191
- 1, # type: method
192
- id, # channel id
193
- frame_size, # frame size
194
- 40, # class: exchange
195
- 40, # method: unbind
196
- 0, # reserved1
197
- destination.bytesize, destination,
198
- source.bytesize, source,
199
- binding_key.bytesize, binding_key,
200
- no_wait ? 1 : 0,
201
- tbl.bytesize, tbl, # arguments
202
- 206 # frame end
203
- ].pack("C S> L> S> S> S> Ca* Ca* Ca* C L>a* C")
204
- end
205
-
206
- def queue_declare(id, name, passive, durable, exclusive, auto_delete, arguments)
207
- no_wait = false
208
- bits = 0
209
- bits |= (1 << 0) if passive
210
- bits |= (1 << 1) if durable
211
- bits |= (1 << 2) if exclusive
212
- bits |= (1 << 3) if auto_delete
213
- bits |= (1 << 4) if no_wait
214
- tbl = Table.encode(arguments)
215
- frame_size = 2 + 2 + 2 + 1 + name.bytesize + 1 + 4 + tbl.bytesize
216
- [
217
- 1, # type: method
218
- id, # channel id
219
- frame_size, # frame size
220
- 50, # class: queue
221
- 10, # method: declare
222
- 0, # reserved1
223
- name.bytesize, name,
224
- bits,
225
- tbl.bytesize, tbl, # arguments
226
- 206 # frame end
227
- ].pack("C S> L> S> S> S> Ca* C L>a* C")
228
- end
229
-
230
- def queue_delete(id, name, if_unused, if_empty, no_wait)
231
- bits = 0
232
- bits |= (1 << 0) if if_unused
233
- bits |= (1 << 1) if if_empty
234
- bits |= (1 << 2) if no_wait
235
- frame_size = 2 + 2 + 2 + 1 + name.bytesize + 1
236
- [
237
- 1, # type: method
238
- id, # channel id
239
- frame_size, # frame size
240
- 50, # class: queue
241
- 40, # method: declare
242
- 0, # reserved1
243
- name.bytesize, name,
244
- bits,
245
- 206 # frame end
246
- ].pack("C S> L> S> S> S> Ca* C C")
247
- end
248
-
249
- def queue_bind(id, queue, exchange, binding_key, no_wait, arguments)
250
- tbl = Table.encode(arguments)
251
- frame_size = 2 + 2 + 2 + 1 + queue.bytesize + 1 + exchange.bytesize + 1 +
252
- binding_key.bytesize + 1 + 4 + tbl.bytesize
253
- [
254
- 1, # type: method
255
- id, # channel id
256
- frame_size, # frame size
257
- 50, # class: queue
258
- 20, # method: bind
259
- 0, # reserved1
260
- queue.bytesize, queue,
261
- exchange.bytesize, exchange,
262
- binding_key.bytesize, binding_key,
263
- no_wait ? 1 : 0,
264
- tbl.bytesize, tbl, # arguments
265
- 206 # frame end
266
- ].pack("C S> L> S> S> S> Ca* Ca* Ca* C L>a* C")
267
- end
268
-
269
- def queue_unbind(id, queue, exchange, binding_key, arguments)
270
- tbl = Table.encode(arguments)
271
- frame_size = 2 + 2 + 2 + 1 + queue.bytesize + 1 + exchange.bytesize + 1 + binding_key.bytesize + 4 + tbl.bytesize
272
- [
273
- 1, # type: method
274
- id, # channel id
275
- frame_size, # frame size
276
- 50, # class: queue
277
- 50, # method: unbind
278
- 0, # reserved1
279
- queue.bytesize, queue,
280
- exchange.bytesize, exchange,
281
- binding_key.bytesize, binding_key,
282
- tbl.bytesize, tbl, # arguments
283
- 206 # frame end
284
- ].pack("C S> L> S> S> S> Ca* Ca* Ca* L>a* C")
285
- end
286
-
287
- def queue_purge(id, queue, no_wait)
288
- frame_size = 2 + 2 + 2 + 1 + queue.bytesize + 1
289
- [
290
- 1, # type: method
291
- id, # channel id
292
- frame_size, # frame size
293
- 50, # class: queue
294
- 30, # method: purge
295
- 0, # reserved1
296
- queue.bytesize, queue,
297
- no_wait ? 1 : 0,
298
- 206 # frame end
299
- ].pack("C S> L> S> S> S> Ca* C C")
300
- end
301
-
302
- def basic_get(id, queue, no_ack)
303
- frame_size = 2 + 2 + 2 + 1 + queue.bytesize + 1
304
- [
305
- 1, # type: method
306
- id, # channel id
307
- frame_size, # frame size
308
- 60, # class: basic
309
- 70, # method: get
310
- 0, # reserved1
311
- queue.bytesize, queue,
312
- no_ack ? 1 : 0,
313
- 206 # frame end
314
- ].pack("C S> L> S> S> S> Ca* C C")
315
- end
316
-
317
- def basic_publish(id, exchange, routing_key, mandatory)
318
- frame_size = 2 + 2 + 2 + 1 + exchange.bytesize + 1 + routing_key.bytesize + 1
319
- [
320
- 1, # type: method
321
- id, # channel id
322
- frame_size, # frame size
323
- 60, # class: basic
324
- 40, # method: publish
325
- 0, # reserved1
326
- exchange.bytesize, exchange,
327
- routing_key.bytesize, routing_key,
328
- mandatory ? 1 : 0, # bits, mandatory/immediate
329
- 206 # frame end
330
- ].pack("C S> L> S> S> S> Ca* Ca* C C")
331
- end
332
-
333
- def header(id, body_size, properties)
334
- props = Properties.new(**properties).encode
335
- frame_size = 2 + 2 + 8 + props.bytesize
336
- [
337
- 2, # type: header
338
- id, # channel id
339
- frame_size, # frame size
340
- 60, # class: basic
341
- 0, # weight
342
- body_size,
343
- props, # properties
344
- 206 # frame end
345
- ].pack("C S> L> S> S> Q> a* C")
346
- end
347
-
348
- def body(id, body_part)
349
- [
350
- 3, # type: body
351
- id, # channel id
352
- body_part.bytesize, # frame size
353
- body_part,
354
- 206 # frame end
355
- ].pack("C S> L> a* C")
356
- end
357
-
358
- def basic_consume(id, queue, tag, no_ack, exclusive, arguments)
359
- no_local = false
360
- no_wait = false
361
- bits = 0
362
- bits |= (1 << 0) if no_local
363
- bits |= (1 << 1) if no_ack
364
- bits |= (1 << 2) if exclusive
365
- bits |= (1 << 3) if no_wait
366
- tbl = Table.encode(arguments)
367
- frame_size = 2 + 2 + 2 + 1 + queue.bytesize + 1 + tag.bytesize + 1 + 4 + tbl.bytesize
368
- [
369
- 1, # type: method
370
- id, # channel id
371
- frame_size, # frame size
372
- 60, # class: basic
373
- 20, # method: consume
374
- 0, # reserved1
375
- queue.bytesize, queue,
376
- tag.bytesize, tag,
377
- bits, # bits
378
- tbl.bytesize, tbl, # arguments
379
- 206 # frame end
380
- ].pack("C S> L> S> S> S> Ca* Ca* C L>a* C")
381
- end
382
-
383
- def basic_cancel(id, consumer_tag, no_wait: false)
384
- frame_size = 2 + 2 + 1 + consumer_tag.bytesize + 1
385
- [
386
- 1, # type: method
387
- id, # channel id
388
- frame_size, # frame size
389
- 60, # class: basic
390
- 30, # method: cancel
391
- consumer_tag.bytesize, consumer_tag,
392
- no_wait ? 1 : 0,
393
- 206 # frame end
394
- ].pack("C S> L> S> S> Ca* C C")
395
- end
396
-
397
- def basic_cancel_ok(id, consumer_tag)
398
- frame_size = 2 + 2 + 1 + consumer_tag.bytesize + 1
399
- [
400
- 1, # type: method
401
- id, # channel id
402
- frame_size, # frame size
403
- 60, # class: basic
404
- 31, # method: cancel-ok
405
- consumer_tag.bytesize, consumer_tag,
406
- 206 # frame end
407
- ].pack("C S> L> S> S> Ca* C")
408
- end
409
-
410
- def basic_ack(id, delivery_tag, multiple)
411
- frame_size = 2 + 2 + 8 + 1
412
- [
413
- 1, # type: method
414
- id, # channel id
415
- frame_size, # frame size
416
- 60, # class: basic
417
- 80, # method: ack
418
- delivery_tag,
419
- multiple ? 1 : 0,
420
- 206 # frame end
421
- ].pack("C S> L> S> S> Q> C C")
422
- end
423
-
424
- def basic_nack(id, delivery_tag, multiple, requeue)
425
- bits = 0
426
- bits |= (1 << 0) if multiple
427
- bits |= (1 << 1) if requeue
428
- frame_size = 2 + 2 + 8 + 1
429
- [
430
- 1, # type: method
431
- id, # channel id
432
- frame_size, # frame size
433
- 60, # class: basic
434
- 120, # method: nack
435
- delivery_tag,
436
- bits,
437
- 206 # frame end
438
- ].pack("C S> L> S> S> Q> C C")
439
- end
440
-
441
- def basic_reject(id, delivery_tag, requeue)
442
- frame_size = 2 + 2 + 8 + 1
443
- [
444
- 1, # type: method
445
- id, # channel id
446
- frame_size, # frame size
447
- 60, # class: basic
448
- 90, # method: reject
449
- delivery_tag,
450
- requeue ? 1 : 0,
451
- 206 # frame end
452
- ].pack("C S> L> S> S> Q> C C")
453
- end
454
-
455
- def basic_qos(id, prefetch_size, prefetch_count, global)
456
- frame_size = 2 + 2 + 4 + 2 + 1
457
- [
458
- 1, # type: method
459
- id, # channel id
460
- frame_size, # frame size
461
- 60, # class: basic
462
- 10, # method: qos
463
- prefetch_size,
464
- prefetch_count,
465
- global ? 1 : 0,
466
- 206 # frame end
467
- ].pack("C S> L> S> S> L> S> C C")
468
- end
469
-
470
- def basic_recover(id, requeue)
471
- frame_size = 2 + 2 + 1
472
- [
473
- 1, # type: method
474
- id, # channel id
475
- frame_size, # frame size
476
- 60, # class: basic
477
- 110, # method: recover
478
- requeue ? 1 : 0,
479
- 206 # frame end
480
- ].pack("C S> L> S> S> C C")
481
- end
482
-
483
- def confirm_select(id, no_wait)
484
- [
485
- 1, # type: method
486
- id, # channel id
487
- 5, # frame size
488
- 85, # class: confirm
489
- 10, # method: select
490
- no_wait ? 1 : 0,
491
- 206 # frame end
492
- ].pack("C S> L> S> S> C C")
493
- end
494
-
495
- def tx_select(id)
496
- frame_size = 2 + 2
497
- [
498
- 1, # type: method
499
- id, # channel id
500
- frame_size, # frame size
501
- 90, # class: tx
502
- 10, # method: select
503
- 206 # frame end
504
- ].pack("C S> L> S> S> C")
505
- end
506
-
507
- def tx_commit(id)
508
- frame_size = 2 + 2
509
- [
510
- 1, # type: method
511
- id, # channel id
512
- frame_size, # frame size
513
- 90, # class: tx
514
- 20, # method: commit
515
- 206 # frame end
516
- ].pack("C S> L> S> S> C")
517
- end
518
-
519
- def tx_rollback(id)
520
- frame_size = 2 + 2
521
- [
522
- 1, # type: method
523
- id, # channel id
524
- frame_size, # frame size
525
- 90, # class: tx
526
- 30, # method: rollback
527
- 206 # frame end
528
- ].pack("C S> L> S> S> C")
529
- end
530
- end
531
- end