rabbitmq 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rabbitmq/channel.rb +7 -4
- data/lib/rabbitmq/connection.rb +3 -1
- data/lib/rabbitmq/ffi/ext.rb +15 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb846b463a46e8d88e17f6ee64caab80faa6b1b5
|
4
|
+
data.tar.gz: 7f4107feb512e7aa9abae32264536623453baa6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ea282404a15b85ce764bd989e12f14bc2b7f2d604d57351fc5545eae25de47531bb9ab5661aab657ecd0f428f8bf6c0c5b4b8a46ea29a5263ae8b5fa35f3124
|
7
|
+
data.tar.gz: 6b22c1156bec01feaf4cec670ad2222011680485db27110818f3fc12a7909698ceb9109029de4f7dc14668a3d630e2d622af06b805b3291ac4ae3fefdd78373a
|
data/lib/rabbitmq/channel.rb
CHANGED
@@ -58,7 +58,7 @@ module RabbitMQ
|
|
58
58
|
end
|
59
59
|
|
60
60
|
private def rpc(request_type, params=[{}], response_type)
|
61
|
-
@connection.send_request(@id, request_type, params.last)
|
61
|
+
@connection.send_request(@id, request_type, params.last || {})
|
62
62
|
if response_type
|
63
63
|
@connection.fetch_response(@id, response_type)
|
64
64
|
else
|
@@ -223,9 +223,9 @@ module RabbitMQ
|
|
223
223
|
end
|
224
224
|
|
225
225
|
def basic_publish(body, exchange, routing_key, **opts)
|
226
|
-
body = FFI::Bytes.from_s(body
|
227
|
-
exchange = FFI::Bytes.from_s(exchange
|
228
|
-
routing_key = FFI::Bytes.from_s(routing_key
|
226
|
+
body = FFI::Bytes.from_s(body)
|
227
|
+
exchange = FFI::Bytes.from_s(exchange)
|
228
|
+
routing_key = FFI::Bytes.from_s(routing_key)
|
229
229
|
properties = FFI::BasicProperties.new.apply(
|
230
230
|
content_type: opts.fetch(:content_type, nil),
|
231
231
|
content_encoding: opts.fetch(:content_encoding, nil),
|
@@ -252,6 +252,9 @@ module RabbitMQ
|
|
252
252
|
body
|
253
253
|
)
|
254
254
|
|
255
|
+
body.free!
|
256
|
+
exchange.free!
|
257
|
+
routing_key.free!
|
255
258
|
properties.free!
|
256
259
|
true
|
257
260
|
end
|
data/lib/rabbitmq/connection.rb
CHANGED
@@ -12,6 +12,8 @@ module RabbitMQ
|
|
12
12
|
@event_handlers = Hash.new { |h,k| h[k] = {} }
|
13
13
|
@incoming_events = Hash.new { |h,k| h[k] = {} }
|
14
14
|
|
15
|
+
@frame = FFI::Frame.new
|
16
|
+
|
15
17
|
create_socket!
|
16
18
|
|
17
19
|
@finalizer = self.class.send :create_finalizer_for, @ptr
|
@@ -255,7 +257,7 @@ module RabbitMQ
|
|
255
257
|
|
256
258
|
# Return the next available frame, or nil if time expired.
|
257
259
|
private def fetch_next_frame(timeout=0, start=Time.now)
|
258
|
-
frame
|
260
|
+
frame = @frame
|
259
261
|
|
260
262
|
# Try fetching the next frame without a blocking call.
|
261
263
|
status = FFI.amqp_simple_wait_frame_noblock(@ptr, frame, FFI::Timeval.zero)
|
data/lib/rabbitmq/ffi/ext.rb
CHANGED
@@ -33,17 +33,13 @@ module RabbitMQ
|
|
33
33
|
clear
|
34
34
|
end
|
35
35
|
|
36
|
-
def self.from_s(str
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
bytes[:bytes].write_string(str)
|
44
|
-
bytes[:len] = size
|
45
|
-
bytes
|
46
|
-
end
|
36
|
+
def self.from_s(str)
|
37
|
+
size = str.bytesize
|
38
|
+
bytes = FFI.amqp_bytes_malloc(size)
|
39
|
+
|
40
|
+
bytes[:bytes].write_string(str)
|
41
|
+
bytes[:len] = size
|
42
|
+
bytes
|
47
43
|
end
|
48
44
|
end
|
49
45
|
|
@@ -80,10 +76,10 @@ module RabbitMQ
|
|
80
76
|
clear
|
81
77
|
end
|
82
78
|
|
83
|
-
def self.from(value
|
79
|
+
def self.from(value)
|
84
80
|
obj = new
|
85
81
|
obj[:kind], obj[:value] = case value
|
86
|
-
when String; [:bytes, FieldValueValue.new(Bytes.from_s(value
|
82
|
+
when String; [:bytes, FieldValueValue.new(Bytes.from_s(value).pointer)]
|
87
83
|
else raise NotImplementedError
|
88
84
|
end
|
89
85
|
obj
|
@@ -119,13 +115,13 @@ module RabbitMQ
|
|
119
115
|
clear
|
120
116
|
end
|
121
117
|
|
122
|
-
def self.from(params
|
118
|
+
def self.from(params)
|
123
119
|
size = params.size
|
124
120
|
entry_ptr = Util.mem_ptr(size * FFI::TableEntry.size, release: false)
|
125
121
|
params.each_with_index do |param, idx|
|
126
122
|
entry = FFI::TableEntry.new(entry_ptr + idx * FFI::TableEntry.size)
|
127
|
-
entry[:key] = FFI::Bytes.from_s(param.first.to_s
|
128
|
-
entry[:value] = FFI::FieldValue.from(param.last
|
123
|
+
entry[:key] = FFI::Bytes.from_s(param.first.to_s)
|
124
|
+
entry[:value] = FFI::FieldValue.from(param.last)
|
129
125
|
end
|
130
126
|
|
131
127
|
obj = new
|
@@ -179,12 +175,12 @@ module RabbitMQ
|
|
179
175
|
end
|
180
176
|
|
181
177
|
module MethodClassMixin
|
182
|
-
def apply(
|
178
|
+
def apply(**params)
|
183
179
|
params.each do |key, value|
|
184
180
|
next if value.nil? || !writable_key?(key)
|
185
181
|
case value
|
186
|
-
when String; value = FFI::Bytes.from_s(value
|
187
|
-
when Hash; value = FFI::Table.from(value
|
182
|
+
when String; value = FFI::Bytes.from_s(value)
|
183
|
+
when Hash; value = FFI::Table.from(value)
|
188
184
|
end
|
189
185
|
key_applied_hook(key)
|
190
186
|
self[key] = value
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbitmq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe McIlvain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|