log4ever 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +7 -1
- data/README.md +3 -1
- data/lib/log4r/evernote.rb +10 -24
- data/lib/log4r/outputter/evernoteoutputter.rb +3 -11
- data/log4ever.gemspec +2 -1
- data/spec/log4ever_spec.rb +24 -17
- metadata +40 -58
- data/.project +0 -11
- data/lib/log4r/evernote/lib/Evernote/EDAM/errors_constants.rb +0 -14
- data/lib/log4r/evernote/lib/Evernote/EDAM/errors_types.rb +0 -128
- data/lib/log4r/evernote/lib/Evernote/EDAM/limits_constants.rb +0 -240
- data/lib/log4r/evernote/lib/Evernote/EDAM/limits_types.rb +0 -13
- data/lib/log4r/evernote/lib/Evernote/EDAM/note_store.rb +0 -5487
- data/lib/log4r/evernote/lib/Evernote/EDAM/note_store_constants.rb +0 -14
- data/lib/log4r/evernote/lib/Evernote/EDAM/note_store_types.rb +0 -1012
- data/lib/log4r/evernote/lib/Evernote/EDAM/types_constants.rb +0 -20
- data/lib/log4r/evernote/lib/Evernote/EDAM/types_types.rb +0 -1792
- data/lib/log4r/evernote/lib/Evernote/EDAM/user_store.rb +0 -549
- data/lib/log4r/evernote/lib/Evernote/EDAM/user_store_constants.rb +0 -18
- data/lib/log4r/evernote/lib/Evernote/EDAM/user_store_types.rb +0 -415
- data/lib/log4r/evernote/lib/thrift/client.rb +0 -62
- data/lib/log4r/evernote/lib/thrift/core_ext/fixnum.rb +0 -29
- data/lib/log4r/evernote/lib/thrift/core_ext.rb +0 -23
- data/lib/log4r/evernote/lib/thrift/exceptions.rb +0 -84
- data/lib/log4r/evernote/lib/thrift/processor.rb +0 -57
- data/lib/log4r/evernote/lib/thrift/protocol/base_protocol.rb +0 -290
- data/lib/log4r/evernote/lib/thrift/protocol/binary_protocol.rb +0 -229
- data/lib/log4r/evernote/lib/thrift/protocol/binary_protocol_accelerated.rb +0 -39
- data/lib/log4r/evernote/lib/thrift/protocol/compact_protocol.rb +0 -426
- data/lib/log4r/evernote/lib/thrift/serializer/deserializer.rb +0 -33
- data/lib/log4r/evernote/lib/thrift/serializer/serializer.rb +0 -34
- data/lib/log4r/evernote/lib/thrift/server/base_server.rb +0 -31
- data/lib/log4r/evernote/lib/thrift/server/mongrel_http_server.rb +0 -58
- data/lib/log4r/evernote/lib/thrift/server/nonblocking_server.rb +0 -305
- data/lib/log4r/evernote/lib/thrift/server/simple_server.rb +0 -43
- data/lib/log4r/evernote/lib/thrift/server/thread_pool_server.rb +0 -75
- data/lib/log4r/evernote/lib/thrift/server/threaded_server.rb +0 -47
- data/lib/log4r/evernote/lib/thrift/struct.rb +0 -237
- data/lib/log4r/evernote/lib/thrift/struct_union.rb +0 -192
- data/lib/log4r/evernote/lib/thrift/thrift_native.rb +0 -24
- data/lib/log4r/evernote/lib/thrift/transport/base_server_transport.rb +0 -37
- data/lib/log4r/evernote/lib/thrift/transport/base_transport.rb +0 -107
- data/lib/log4r/evernote/lib/thrift/transport/buffered_transport.rb +0 -108
- data/lib/log4r/evernote/lib/thrift/transport/framed_transport.rb +0 -116
- data/lib/log4r/evernote/lib/thrift/transport/http_client_transport.rb +0 -53
- data/lib/log4r/evernote/lib/thrift/transport/io_stream_transport.rb +0 -39
- data/lib/log4r/evernote/lib/thrift/transport/memory_buffer_transport.rb +0 -125
- data/lib/log4r/evernote/lib/thrift/transport/server_socket.rb +0 -63
- data/lib/log4r/evernote/lib/thrift/transport/socket.rb +0 -137
- data/lib/log4r/evernote/lib/thrift/transport/unix_server_socket.rb +0 -60
- data/lib/log4r/evernote/lib/thrift/transport/unix_socket.rb +0 -40
- data/lib/log4r/evernote/lib/thrift/types.rb +0 -101
- data/lib/log4r/evernote/lib/thrift/union.rb +0 -179
- data/lib/log4r/evernote/lib/thrift.rb +0 -64
@@ -1,290 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
# this require is to make generated struct definitions happy
|
21
|
-
require 'set'
|
22
|
-
|
23
|
-
module Thrift
|
24
|
-
class ProtocolException < Exception
|
25
|
-
|
26
|
-
UNKNOWN = 0
|
27
|
-
INVALID_DATA = 1
|
28
|
-
NEGATIVE_SIZE = 2
|
29
|
-
SIZE_LIMIT = 3
|
30
|
-
BAD_VERSION = 4
|
31
|
-
|
32
|
-
attr_reader :type
|
33
|
-
|
34
|
-
def initialize(type=UNKNOWN, message=nil)
|
35
|
-
super(message)
|
36
|
-
@type = type
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class BaseProtocol
|
41
|
-
|
42
|
-
attr_reader :trans
|
43
|
-
|
44
|
-
def initialize(trans)
|
45
|
-
@trans = trans
|
46
|
-
end
|
47
|
-
|
48
|
-
def native?
|
49
|
-
puts "wrong method is being called!"
|
50
|
-
false
|
51
|
-
end
|
52
|
-
|
53
|
-
def write_message_begin(name, type, seqid)
|
54
|
-
raise NotImplementedError
|
55
|
-
end
|
56
|
-
|
57
|
-
def write_message_end; nil; end
|
58
|
-
|
59
|
-
def write_struct_begin(name)
|
60
|
-
raise NotImplementedError
|
61
|
-
end
|
62
|
-
|
63
|
-
def write_struct_end; nil; end
|
64
|
-
|
65
|
-
def write_field_begin(name, type, id)
|
66
|
-
raise NotImplementedError
|
67
|
-
end
|
68
|
-
|
69
|
-
def write_field_end; nil; end
|
70
|
-
|
71
|
-
def write_field_stop
|
72
|
-
raise NotImplementedError
|
73
|
-
end
|
74
|
-
|
75
|
-
def write_map_begin(ktype, vtype, size)
|
76
|
-
raise NotImplementedError
|
77
|
-
end
|
78
|
-
|
79
|
-
def write_map_end; nil; end
|
80
|
-
|
81
|
-
def write_list_begin(etype, size)
|
82
|
-
raise NotImplementedError
|
83
|
-
end
|
84
|
-
|
85
|
-
def write_list_end; nil; end
|
86
|
-
|
87
|
-
def write_set_begin(etype, size)
|
88
|
-
raise NotImplementedError
|
89
|
-
end
|
90
|
-
|
91
|
-
def write_set_end; nil; end
|
92
|
-
|
93
|
-
def write_bool(bool)
|
94
|
-
raise NotImplementedError
|
95
|
-
end
|
96
|
-
|
97
|
-
def write_byte(byte)
|
98
|
-
raise NotImplementedError
|
99
|
-
end
|
100
|
-
|
101
|
-
def write_i16(i16)
|
102
|
-
raise NotImplementedError
|
103
|
-
end
|
104
|
-
|
105
|
-
def write_i32(i32)
|
106
|
-
raise NotImplementedError
|
107
|
-
end
|
108
|
-
|
109
|
-
def write_i64(i64)
|
110
|
-
raise NotImplementedError
|
111
|
-
end
|
112
|
-
|
113
|
-
def write_double(dub)
|
114
|
-
raise NotImplementedError
|
115
|
-
end
|
116
|
-
|
117
|
-
def write_string(str)
|
118
|
-
raise NotImplementedError
|
119
|
-
end
|
120
|
-
|
121
|
-
def read_message_begin
|
122
|
-
raise NotImplementedError
|
123
|
-
end
|
124
|
-
|
125
|
-
def read_message_end; nil; end
|
126
|
-
|
127
|
-
def read_struct_begin
|
128
|
-
raise NotImplementedError
|
129
|
-
end
|
130
|
-
|
131
|
-
def read_struct_end; nil; end
|
132
|
-
|
133
|
-
def read_field_begin
|
134
|
-
raise NotImplementedError
|
135
|
-
end
|
136
|
-
|
137
|
-
def read_field_end; nil; end
|
138
|
-
|
139
|
-
def read_map_begin
|
140
|
-
raise NotImplementedError
|
141
|
-
end
|
142
|
-
|
143
|
-
def read_map_end; nil; end
|
144
|
-
|
145
|
-
def read_list_begin
|
146
|
-
raise NotImplementedError
|
147
|
-
end
|
148
|
-
|
149
|
-
def read_list_end; nil; end
|
150
|
-
|
151
|
-
def read_set_begin
|
152
|
-
raise NotImplementedError
|
153
|
-
end
|
154
|
-
|
155
|
-
def read_set_end; nil; end
|
156
|
-
|
157
|
-
def read_bool
|
158
|
-
raise NotImplementedError
|
159
|
-
end
|
160
|
-
|
161
|
-
def read_byte
|
162
|
-
raise NotImplementedError
|
163
|
-
end
|
164
|
-
|
165
|
-
def read_i16
|
166
|
-
raise NotImplementedError
|
167
|
-
end
|
168
|
-
|
169
|
-
def read_i32
|
170
|
-
raise NotImplementedError
|
171
|
-
end
|
172
|
-
|
173
|
-
def read_i64
|
174
|
-
raise NotImplementedError
|
175
|
-
end
|
176
|
-
|
177
|
-
def read_double
|
178
|
-
raise NotImplementedError
|
179
|
-
end
|
180
|
-
|
181
|
-
def read_string
|
182
|
-
raise NotImplementedError
|
183
|
-
end
|
184
|
-
|
185
|
-
def write_field(name, type, fid, value)
|
186
|
-
write_field_begin(name, type, fid)
|
187
|
-
write_type(type, value)
|
188
|
-
write_field_end
|
189
|
-
end
|
190
|
-
|
191
|
-
def write_type(type, value)
|
192
|
-
case type
|
193
|
-
when Types::BOOL
|
194
|
-
write_bool(value)
|
195
|
-
when Types::BYTE
|
196
|
-
write_byte(value)
|
197
|
-
when Types::DOUBLE
|
198
|
-
write_double(value)
|
199
|
-
when Types::I16
|
200
|
-
write_i16(value)
|
201
|
-
when Types::I32
|
202
|
-
write_i32(value)
|
203
|
-
when Types::I64
|
204
|
-
write_i64(value)
|
205
|
-
when Types::STRING
|
206
|
-
write_string(value)
|
207
|
-
when Types::STRUCT
|
208
|
-
value.write(self)
|
209
|
-
else
|
210
|
-
raise NotImplementedError
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
def read_type(type)
|
215
|
-
case type
|
216
|
-
when Types::BOOL
|
217
|
-
read_bool
|
218
|
-
when Types::BYTE
|
219
|
-
read_byte
|
220
|
-
when Types::DOUBLE
|
221
|
-
read_double
|
222
|
-
when Types::I16
|
223
|
-
read_i16
|
224
|
-
when Types::I32
|
225
|
-
read_i32
|
226
|
-
when Types::I64
|
227
|
-
read_i64
|
228
|
-
when Types::STRING
|
229
|
-
read_string
|
230
|
-
else
|
231
|
-
raise NotImplementedError
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
def skip(type)
|
236
|
-
case type
|
237
|
-
when Types::STOP
|
238
|
-
nil
|
239
|
-
when Types::BOOL
|
240
|
-
read_bool
|
241
|
-
when Types::BYTE
|
242
|
-
read_byte
|
243
|
-
when Types::I16
|
244
|
-
read_i16
|
245
|
-
when Types::I32
|
246
|
-
read_i32
|
247
|
-
when Types::I64
|
248
|
-
read_i64
|
249
|
-
when Types::DOUBLE
|
250
|
-
read_double
|
251
|
-
when Types::STRING
|
252
|
-
read_string
|
253
|
-
when Types::STRUCT
|
254
|
-
read_struct_begin
|
255
|
-
while true
|
256
|
-
name, type, id = read_field_begin
|
257
|
-
break if type == Types::STOP
|
258
|
-
skip(type)
|
259
|
-
read_field_end
|
260
|
-
end
|
261
|
-
read_struct_end
|
262
|
-
when Types::MAP
|
263
|
-
ktype, vtype, size = read_map_begin
|
264
|
-
size.times do
|
265
|
-
skip(ktype)
|
266
|
-
skip(vtype)
|
267
|
-
end
|
268
|
-
read_map_end
|
269
|
-
when Types::SET
|
270
|
-
etype, size = read_set_begin
|
271
|
-
size.times do
|
272
|
-
skip(etype)
|
273
|
-
end
|
274
|
-
read_set_end
|
275
|
-
when Types::LIST
|
276
|
-
etype, size = read_list_begin
|
277
|
-
size.times do
|
278
|
-
skip(etype)
|
279
|
-
end
|
280
|
-
read_list_end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
class BaseProtocolFactory
|
286
|
-
def get_protocol(trans)
|
287
|
-
raise NotImplementedError
|
288
|
-
end
|
289
|
-
end
|
290
|
-
end
|
@@ -1,229 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
module Thrift
|
21
|
-
class BinaryProtocol < BaseProtocol
|
22
|
-
VERSION_MASK = 0xffff0000
|
23
|
-
VERSION_1 = 0x80010000
|
24
|
-
TYPE_MASK = 0x000000ff
|
25
|
-
|
26
|
-
attr_reader :strict_read, :strict_write
|
27
|
-
|
28
|
-
def initialize(trans, strict_read=true, strict_write=true)
|
29
|
-
super(trans)
|
30
|
-
@strict_read = strict_read
|
31
|
-
@strict_write = strict_write
|
32
|
-
|
33
|
-
# Pre-allocated read buffer for fixed-size read methods. Needs to be at least 8 bytes long for
|
34
|
-
# read_i64() and read_double().
|
35
|
-
@rbuf = "\0" * 8
|
36
|
-
@rbuf.force_encoding("BINARY") if @rbuf.respond_to?(:force_encoding)
|
37
|
-
end
|
38
|
-
|
39
|
-
def write_message_begin(name, type, seqid)
|
40
|
-
# this is necessary because we added (needed) bounds checking to
|
41
|
-
# write_i32, and 0x80010000 is too big for that.
|
42
|
-
if strict_write
|
43
|
-
write_i16(VERSION_1 >> 16)
|
44
|
-
write_i16(type)
|
45
|
-
write_string(name)
|
46
|
-
write_i32(seqid)
|
47
|
-
else
|
48
|
-
write_string(name)
|
49
|
-
write_byte(type)
|
50
|
-
write_i32(seqid)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def write_struct_begin(name); nil; end
|
55
|
-
|
56
|
-
def write_field_begin(name, type, id)
|
57
|
-
write_byte(type)
|
58
|
-
write_i16(id)
|
59
|
-
end
|
60
|
-
|
61
|
-
def write_field_stop
|
62
|
-
write_byte(Thrift::Types::STOP)
|
63
|
-
end
|
64
|
-
|
65
|
-
def write_map_begin(ktype, vtype, size)
|
66
|
-
write_byte(ktype)
|
67
|
-
write_byte(vtype)
|
68
|
-
write_i32(size)
|
69
|
-
end
|
70
|
-
|
71
|
-
def write_list_begin(etype, size)
|
72
|
-
write_byte(etype)
|
73
|
-
write_i32(size)
|
74
|
-
end
|
75
|
-
|
76
|
-
def write_set_begin(etype, size)
|
77
|
-
write_byte(etype)
|
78
|
-
write_i32(size)
|
79
|
-
end
|
80
|
-
|
81
|
-
def write_bool(bool)
|
82
|
-
write_byte(bool ? 1 : 0)
|
83
|
-
end
|
84
|
-
|
85
|
-
def write_byte(byte)
|
86
|
-
raise RangeError if byte < -2**31 || byte >= 2**32
|
87
|
-
trans.write([byte].pack('c'))
|
88
|
-
end
|
89
|
-
|
90
|
-
def write_i16(i16)
|
91
|
-
trans.write([i16].pack('n'))
|
92
|
-
end
|
93
|
-
|
94
|
-
def write_i32(i32)
|
95
|
-
raise RangeError if i32 < -2**31 || i32 >= 2**31
|
96
|
-
trans.write([i32].pack('N'))
|
97
|
-
end
|
98
|
-
|
99
|
-
def write_i64(i64)
|
100
|
-
raise RangeError if i64 < -2**63 || i64 >= 2**64
|
101
|
-
hi = i64 >> 32
|
102
|
-
lo = i64 & 0xffffffff
|
103
|
-
trans.write([hi, lo].pack('N2'))
|
104
|
-
end
|
105
|
-
|
106
|
-
def write_double(dub)
|
107
|
-
trans.write([dub].pack('G'))
|
108
|
-
end
|
109
|
-
|
110
|
-
def write_string(str)
|
111
|
-
write_i32(str.length)
|
112
|
-
trans.write(str)
|
113
|
-
end
|
114
|
-
|
115
|
-
def read_message_begin
|
116
|
-
version = read_i32
|
117
|
-
if version < 0
|
118
|
-
if (version & VERSION_MASK != VERSION_1)
|
119
|
-
raise ProtocolException.new(ProtocolException::BAD_VERSION, 'Missing version identifier')
|
120
|
-
end
|
121
|
-
type = version & TYPE_MASK
|
122
|
-
name = read_string
|
123
|
-
seqid = read_i32
|
124
|
-
[name, type, seqid]
|
125
|
-
else
|
126
|
-
if strict_read
|
127
|
-
raise ProtocolException.new(ProtocolException::BAD_VERSION, 'No version identifier, old protocol client?')
|
128
|
-
end
|
129
|
-
name = trans.read_all(version)
|
130
|
-
type = read_byte
|
131
|
-
seqid = read_i32
|
132
|
-
[name, type, seqid]
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def read_struct_begin; nil; end
|
137
|
-
|
138
|
-
def read_field_begin
|
139
|
-
type = read_byte
|
140
|
-
if (type == Types::STOP)
|
141
|
-
[nil, type, 0]
|
142
|
-
else
|
143
|
-
id = read_i16
|
144
|
-
[nil, type, id]
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def read_map_begin
|
149
|
-
ktype = read_byte
|
150
|
-
vtype = read_byte
|
151
|
-
size = read_i32
|
152
|
-
[ktype, vtype, size]
|
153
|
-
end
|
154
|
-
|
155
|
-
def read_list_begin
|
156
|
-
etype = read_byte
|
157
|
-
size = read_i32
|
158
|
-
[etype, size]
|
159
|
-
end
|
160
|
-
|
161
|
-
def read_set_begin
|
162
|
-
etype = read_byte
|
163
|
-
size = read_i32
|
164
|
-
[etype, size]
|
165
|
-
end
|
166
|
-
|
167
|
-
def read_bool
|
168
|
-
byte = read_byte
|
169
|
-
byte != 0
|
170
|
-
end
|
171
|
-
|
172
|
-
def read_byte
|
173
|
-
val = trans.read_byte
|
174
|
-
if (val > 0x7f)
|
175
|
-
val = 0 - ((val - 1) ^ 0xff)
|
176
|
-
end
|
177
|
-
val
|
178
|
-
end
|
179
|
-
|
180
|
-
def read_i16
|
181
|
-
trans.read_into_buffer(@rbuf, 2)
|
182
|
-
val, = @rbuf.unpack('n')
|
183
|
-
if (val > 0x7fff)
|
184
|
-
val = 0 - ((val - 1) ^ 0xffff)
|
185
|
-
end
|
186
|
-
val
|
187
|
-
end
|
188
|
-
|
189
|
-
def read_i32
|
190
|
-
trans.read_into_buffer(@rbuf, 4)
|
191
|
-
val, = @rbuf.unpack('N')
|
192
|
-
if (val > 0x7fffffff)
|
193
|
-
val = 0 - ((val - 1) ^ 0xffffffff)
|
194
|
-
end
|
195
|
-
val
|
196
|
-
end
|
197
|
-
|
198
|
-
def read_i64
|
199
|
-
trans.read_into_buffer(@rbuf, 8)
|
200
|
-
hi, lo = @rbuf.unpack('N2')
|
201
|
-
if (hi > 0x7fffffff)
|
202
|
-
hi ^= 0xffffffff
|
203
|
-
lo ^= 0xffffffff
|
204
|
-
0 - (hi << 32) - lo - 1
|
205
|
-
else
|
206
|
-
(hi << 32) + lo
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def read_double
|
211
|
-
trans.read_into_buffer(@rbuf, 8)
|
212
|
-
val = @rbuf.unpack('G').first
|
213
|
-
val
|
214
|
-
end
|
215
|
-
|
216
|
-
def read_string
|
217
|
-
sz = read_i32
|
218
|
-
dat = trans.read_all(sz)
|
219
|
-
dat
|
220
|
-
end
|
221
|
-
|
222
|
-
end
|
223
|
-
|
224
|
-
class BinaryProtocolFactory < BaseProtocolFactory
|
225
|
-
def get_protocol(trans)
|
226
|
-
return Thrift::BinaryProtocol.new(trans)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
4
|
-
# distributed with this work for additional information
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
7
|
-
# "License"); you may not use this file except in compliance
|
8
|
-
# with the License. You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
13
|
-
# software distributed under the License is distributed on an
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
# KIND, either express or implied. See the License for the
|
16
|
-
# specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
=begin
|
21
|
-
The only change required for a transport to support BinaryProtocolAccelerated is to implement 2 methods:
|
22
|
-
* borrow(size), which takes an optional argument and returns atleast _size_ bytes from the transport,
|
23
|
-
or the default buffer size if no argument is given
|
24
|
-
* consume!(size), which removes size bytes from the front of the buffer
|
25
|
-
|
26
|
-
See MemoryBuffer and BufferedTransport for examples.
|
27
|
-
=end
|
28
|
-
|
29
|
-
module Thrift
|
30
|
-
class BinaryProtocolAcceleratedFactory < BaseProtocolFactory
|
31
|
-
def get_protocol(trans)
|
32
|
-
if (defined? BinaryProtocolAccelerated)
|
33
|
-
BinaryProtocolAccelerated.new(trans)
|
34
|
-
else
|
35
|
-
BinaryProtocol.new(trans)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|