celldee-bunny 0.3.1 → 0.4.0
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.
- data/README +3 -0
- data/Rakefile +0 -5
- data/bunny.gemspec +24 -24
- data/lib/bunny/client.rb +22 -22
- data/lib/bunny/exchange.rb +8 -8
- data/lib/bunny/queue.rb +17 -17
- data/lib/bunny.rb +4 -11
- data/lib/qrack/client.rb +5 -0
- data/lib/{bunny → qrack}/protocol/protocol.rb +1 -1
- data/lib/{bunny → qrack}/protocol/spec.rb +245 -259
- data/lib/qrack/qrack.rb +28 -0
- data/lib/{bunny → qrack}/transport/buffer.rb +8 -7
- data/lib/qrack/transport/frame.rb +100 -0
- metadata +8 -8
- data/ext/amqp-0.8.json +0 -617
- data/ext/codegen.rb +0 -177
- data/lib/bunny/transport/frame.rb +0 -62
data/lib/qrack/qrack.rb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
require 'protocol/spec'
|
|
4
|
+
require 'protocol/protocol'
|
|
5
|
+
|
|
6
|
+
require 'transport/buffer'
|
|
7
|
+
require 'transport/frame'
|
|
8
|
+
|
|
9
|
+
require 'client'
|
|
10
|
+
|
|
11
|
+
module Qrack
|
|
12
|
+
|
|
13
|
+
include Protocol
|
|
14
|
+
include Transport
|
|
15
|
+
|
|
16
|
+
# Errors
|
|
17
|
+
class BufferOverflowError < StandardError; end
|
|
18
|
+
class InvalidTypeError < StandardError; end
|
|
19
|
+
|
|
20
|
+
# Qrack version number
|
|
21
|
+
VERSION = '0.0.1'
|
|
22
|
+
|
|
23
|
+
# Return the Qrack version
|
|
24
|
+
def self.version
|
|
25
|
+
VERSION
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
module
|
|
1
|
+
module Qrack
|
|
2
2
|
module Transport #:nodoc: all
|
|
3
3
|
class Buffer
|
|
4
|
-
|
|
4
|
+
require 'enumerator' if RUBY_VERSION < '1.8.7'
|
|
5
|
+
|
|
5
6
|
def initialize data = ''
|
|
6
7
|
@data = data
|
|
7
8
|
@pos = 0
|
|
@@ -123,7 +124,7 @@ module Bunny
|
|
|
123
124
|
|
|
124
125
|
@bits.shift
|
|
125
126
|
else
|
|
126
|
-
raise
|
|
127
|
+
raise Qrack::InvalidTypeError, "Cannot read data of type #{type}"
|
|
127
128
|
end
|
|
128
129
|
end
|
|
129
130
|
|
|
@@ -220,7 +221,7 @@ module Bunny
|
|
|
220
221
|
write(type, value) unless type == :bit
|
|
221
222
|
end
|
|
222
223
|
else
|
|
223
|
-
raise
|
|
224
|
+
raise Qrack::InvalidTypeError, "Cannot write data of type #{type}"
|
|
224
225
|
end
|
|
225
226
|
|
|
226
227
|
self
|
|
@@ -230,21 +231,21 @@ module Bunny
|
|
|
230
231
|
begin
|
|
231
232
|
cur_data, cur_pos = @data.clone, @pos
|
|
232
233
|
yield self
|
|
233
|
-
rescue
|
|
234
|
+
rescue Qrack::BufferOverflowError
|
|
234
235
|
@data, @pos = cur_data, cur_pos
|
|
235
236
|
nil
|
|
236
237
|
end
|
|
237
238
|
end
|
|
238
239
|
|
|
239
240
|
def _read(size, pack = nil)
|
|
240
|
-
if @data.is_a?(
|
|
241
|
+
if @data.is_a?(Qrack::Client)
|
|
241
242
|
raw = @data.read(size)
|
|
242
243
|
return raw if raw.nil? or pack.nil?
|
|
243
244
|
return raw.unpack(pack).first
|
|
244
245
|
end
|
|
245
246
|
|
|
246
247
|
if @pos + size > length
|
|
247
|
-
raise
|
|
248
|
+
raise Qrack::BufferOverflowError
|
|
248
249
|
else
|
|
249
250
|
data = @data[@pos,size]
|
|
250
251
|
@data[@pos,size] = ''
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
|
|
2
|
+
#:stopdoc:
|
|
3
|
+
# this file was autogenerated on Fri May 15 10:11:23 +0100 2009
|
|
4
|
+
#
|
|
5
|
+
# DO NOT EDIT! (edit ext/qparser.rb and config.yml instead, and run 'ruby qparser.rb')
|
|
6
|
+
|
|
7
|
+
module Qrack
|
|
8
|
+
module Transport
|
|
9
|
+
class Frame
|
|
10
|
+
def self.types
|
|
11
|
+
@types ||= {}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.Frame id
|
|
15
|
+
(@_base_frames ||= {})[id] ||= Class.new(Frame) do
|
|
16
|
+
class_eval %[
|
|
17
|
+
def self.inherited klass
|
|
18
|
+
klass.const_set(:ID, #{id})
|
|
19
|
+
Frame.types[#{id}] = klass
|
|
20
|
+
end
|
|
21
|
+
]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class Method < Frame( 1 ); end
|
|
26
|
+
class Header < Frame( 2 ); end
|
|
27
|
+
class Body < Frame( 3 ); end
|
|
28
|
+
class OobMethod < Frame( 4 ); end
|
|
29
|
+
class OobHeader < Frame( 5 ); end
|
|
30
|
+
class OobBody < Frame( 6 ); end
|
|
31
|
+
class Trace < Frame( 7 ); end
|
|
32
|
+
class Heartbeat < Frame( 8 ); end
|
|
33
|
+
|
|
34
|
+
FOOTER = 206
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
module Qrack
|
|
40
|
+
module Transport
|
|
41
|
+
class Frame
|
|
42
|
+
def initialize payload = nil, channel = 0
|
|
43
|
+
@channel, @payload = channel, payload
|
|
44
|
+
end
|
|
45
|
+
attr_accessor :channel, :payload
|
|
46
|
+
|
|
47
|
+
def id
|
|
48
|
+
self.class::ID
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def to_binary
|
|
52
|
+
buf = Transport::Buffer.new
|
|
53
|
+
buf.write :octet, id
|
|
54
|
+
buf.write :short, channel
|
|
55
|
+
buf.write :longstr, payload
|
|
56
|
+
buf.write :octet, Transport::Frame::FOOTER
|
|
57
|
+
buf.rewind
|
|
58
|
+
buf
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def to_s
|
|
62
|
+
to_binary.to_s
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def == frame
|
|
66
|
+
[ :id, :channel, :payload ].inject(true) do |eql, field|
|
|
67
|
+
eql and __send__(field) == frame.__send__(field)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
class Method
|
|
72
|
+
def initialize payload = nil, channel = 0
|
|
73
|
+
super
|
|
74
|
+
unless @payload.is_a? Protocol::Class::Method or @payload.nil?
|
|
75
|
+
@payload = Protocol.parse(@payload)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class Header
|
|
81
|
+
def initialize payload = nil, channel = 0
|
|
82
|
+
super
|
|
83
|
+
unless @payload.is_a? Protocol::Header or @payload.nil?
|
|
84
|
+
@payload = Protocol::Header.new(@payload)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
class Body; end
|
|
90
|
+
|
|
91
|
+
def self.parse buf
|
|
92
|
+
buf = Transport::Buffer.new(buf) unless buf.is_a? Transport::Buffer
|
|
93
|
+
buf.extract do
|
|
94
|
+
id, channel, payload, footer = buf.read(:octet, :short, :longstr, :octet)
|
|
95
|
+
Transport::Frame.types[id].new(payload, channel) if footer == Transport::Frame::FOOTER
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: celldee-bunny
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Duncan
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-05-
|
|
12
|
+
date: 2009-05-15 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|
|
@@ -32,16 +32,16 @@ files:
|
|
|
32
32
|
- examples/simple_fanout.rb
|
|
33
33
|
- examples/simple_publisher.rb
|
|
34
34
|
- examples/simple_topic.rb
|
|
35
|
-
- ext/amqp-0.8.json
|
|
36
|
-
- ext/codegen.rb
|
|
37
35
|
- lib/bunny.rb
|
|
38
36
|
- lib/bunny/client.rb
|
|
39
37
|
- lib/bunny/exchange.rb
|
|
40
|
-
- lib/bunny/protocol/protocol.rb
|
|
41
|
-
- lib/bunny/protocol/spec.rb
|
|
42
38
|
- lib/bunny/queue.rb
|
|
43
|
-
- lib/
|
|
44
|
-
- lib/
|
|
39
|
+
- lib/qrack/client.rb
|
|
40
|
+
- lib/qrack/protocol/protocol.rb
|
|
41
|
+
- lib/qrack/protocol/spec.rb
|
|
42
|
+
- lib/qrack/qrack.rb
|
|
43
|
+
- lib/qrack/transport/buffer.rb
|
|
44
|
+
- lib/qrack/transport/frame.rb
|
|
45
45
|
- spec/bunny_spec.rb
|
|
46
46
|
- spec/exchange_spec.rb
|
|
47
47
|
- spec/queue_spec.rb
|