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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 412b293a10015443e4a02fbe1775a51e5fda11b7
4
- data.tar.gz: dcc35e673f49775c6c3f3c940e04c6b1fbc26def
3
+ metadata.gz: eb846b463a46e8d88e17f6ee64caab80faa6b1b5
4
+ data.tar.gz: 7f4107feb512e7aa9abae32264536623453baa6e
5
5
  SHA512:
6
- metadata.gz: 8f755148f80b5ab2c89ed044528ccf286455654e71ff66e9b872d80818d2700951f0c73486de53adb24a27ece0cbbd2c225ed1dc5f599cac662770bdd7c19628
7
- data.tar.gz: a792ac40dd95400fe151e510f188b87f6dff9e138e3c8c170fe8002a091d053b8426ee95274b1876381e0aeafec6581c142afcb3b1549f4232d64aff55147585
6
+ metadata.gz: 1ea282404a15b85ce764bd989e12f14bc2b7f2d604d57351fc5545eae25de47531bb9ab5661aab657ecd0f428f8bf6c0c5b4b8a46ea29a5263ae8b5fa35f3124
7
+ data.tar.gz: 6b22c1156bec01feaf4cec670ad2222011680485db27110818f3fc12a7909698ceb9109029de4f7dc14668a3d630e2d622af06b805b3291ac4ae3fefdd78373a
@@ -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, true)
227
- exchange = FFI::Bytes.from_s(exchange, true)
228
- routing_key = FFI::Bytes.from_s(routing_key, true)
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
@@ -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 = FFI::Frame.new
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)
@@ -33,17 +33,13 @@ module RabbitMQ
33
33
  clear
34
34
  end
35
35
 
36
- def self.from_s(str, borrow=false)
37
- if borrow
38
- FFI.amqp_cstring_bytes(str)
39
- else
40
- size = str.bytesize
41
- bytes = FFI.amqp_bytes_malloc(size)
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, borrow=false)
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, borrow).pointer)]
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, borrow=false)
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, borrow)
128
- entry[:value] = FFI::FieldValue.from(param.last, borrow)
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(borrow=false, **params)
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, borrow)
187
- when Hash; value = FFI::Table.from(value, borrow)
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.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-09 00:00:00.000000000 Z
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi