thrift 0.0.751142 → 0.0.810255.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.
- data/CHANGELOG +3 -1
- data/Manifest +47 -44
- data/README +19 -6
- data/Rakefile +1 -1
- data/benchmark/Benchmark.thrift +19 -0
- data/benchmark/benchmark.rb +20 -3
- data/benchmark/client.rb +20 -2
- data/benchmark/server.rb +22 -4
- data/benchmark/thin_server.rb +22 -4
- data/ext/binary_protocol_accelerated.c +32 -21
- data/ext/binary_protocol_accelerated.h +19 -0
- data/ext/compact_protocol.c +665 -0
- data/ext/compact_protocol.h +20 -0
- data/ext/constants.h +19 -1
- data/ext/extconf.rb +19 -0
- data/ext/macros.h +41 -0
- data/ext/memory_buffer.c +29 -5
- data/ext/memory_buffer.h +19 -0
- data/ext/protocol.c +20 -1
- data/ext/protocol.h +19 -0
- data/ext/struct.c +115 -83
- data/ext/struct.h +19 -0
- data/ext/thrift_native.c +23 -2
- data/lib/thrift/client.rb +19 -1
- data/lib/thrift/core_ext/fixnum.rb +29 -0
- data/lib/thrift/core_ext.rb +23 -0
- data/lib/thrift/exceptions.rb +19 -2
- data/lib/thrift/processor.rb +19 -1
- data/lib/thrift/protocol/base_protocol.rb +290 -0
- data/lib/thrift/protocol/{binaryprotocol.rb → binary_protocol.rb} +27 -15
- data/lib/thrift/protocol/binary_protocol_accelerated.rb +35 -0
- data/lib/thrift/protocol/compact_protocol.rb +422 -0
- data/lib/thrift/serializer/deserializer.rb +33 -0
- data/lib/thrift/serializer/serializer.rb +34 -0
- data/lib/thrift/server/base_server.rb +31 -0
- data/lib/thrift/server/{httpserver.rb → mongrel_http_server.rb} +19 -5
- data/lib/thrift/server/{nonblockingserver.rb → nonblocking_server.rb} +42 -24
- data/lib/thrift/server/simple_server.rb +43 -0
- data/lib/thrift/server/thread_pool_server.rb +75 -0
- data/lib/thrift/server/threaded_server.rb +47 -0
- data/lib/thrift/struct.rb +73 -47
- data/lib/thrift/thrift_native.rb +24 -0
- data/lib/thrift/transport/base_server_transport.rb +37 -0
- data/lib/thrift/transport/base_transport.rb +70 -0
- data/lib/thrift/transport/buffered_transport.rb +77 -0
- data/lib/thrift/transport/framed_transport.rb +90 -0
- data/lib/thrift/transport/http_client_transport.rb +45 -0
- data/lib/thrift/transport/io_stream_transport.rb +39 -0
- data/lib/thrift/transport/memory_buffer_transport.rb +96 -0
- data/lib/thrift/transport/server_socket.rb +63 -0
- data/lib/thrift/transport/socket.rb +22 -53
- data/lib/thrift/transport/unix_server_socket.rb +60 -0
- data/lib/thrift/transport/unix_socket.rb +40 -0
- data/lib/thrift/types.rb +20 -2
- data/lib/thrift.rb +50 -19
- data/script/proto_benchmark.rb +121 -0
- data/script/read_struct.rb +43 -0
- data/script/write_struct.rb +30 -0
- data/spec/ThriftSpec.thrift +40 -2
- data/spec/{protocol_spec.rb → base_protocol_spec.rb} +25 -7
- data/spec/{transport_spec.rb → base_transport_spec.rb} +44 -52
- data/spec/binary_protocol_accelerated_spec.rb +41 -0
- data/spec/{binaryprotocol_spec.rb → binary_protocol_spec.rb} +20 -2
- data/spec/{binaryprotocol_spec_shared.rb → binary_protocol_spec_shared.rb} +117 -16
- data/spec/client_spec.rb +23 -4
- data/spec/compact_protocol_spec.rb +117 -0
- data/spec/exception_spec.rb +19 -0
- data/spec/http_client_spec.rb +49 -0
- data/spec/{httpserver_spec.rb → mongrel_http_server_spec.rb} +26 -7
- data/spec/{nonblockingserver_spec.rb → nonblocking_server_spec.rb} +25 -5
- data/spec/processor_spec.rb +19 -0
- data/spec/serializer_spec.rb +27 -10
- data/spec/server_socket_spec.rb +80 -0
- data/spec/server_spec.rb +35 -16
- data/spec/socket_spec.rb +19 -55
- data/spec/socket_spec_shared.rb +19 -0
- data/spec/spec_helper.rb +34 -9
- data/spec/struct_spec.rb +26 -18
- data/spec/types_spec.rb +19 -1
- data/spec/{unixsocket_spec.rb → unix_socket_spec.rb} +19 -1
- data/thrift.gemspec +6 -6
- data.tar.gz.sig +0 -0
- metadata +80 -70
- metadata.gz.sig +0 -0
- data/COPYING +0 -14
- data/LICENSE +0 -14
- data/Makefile.am +0 -15
- data/benchmark/gen-rb/BenchmarkService.rb +0 -81
- data/benchmark/gen-rb/Benchmark_constants.rb +0 -11
- data/benchmark/gen-rb/Benchmark_types.rb +0 -10
- data/lib/thrift/deprecation.rb +0 -155
- data/lib/thrift/protocol/binaryprotocolaccelerated.rb +0 -19
- data/lib/thrift/protocol/tbinaryprotocol.rb +0 -2
- data/lib/thrift/protocol/tprotocol.rb +0 -2
- data/lib/thrift/protocol.rb +0 -270
- data/lib/thrift/serializer.rb +0 -27
- data/lib/thrift/server/thttpserver.rb +0 -2
- data/lib/thrift/server/tserver.rb +0 -2
- data/lib/thrift/server.rb +0 -135
- data/lib/thrift/thrift.rb +0 -14
- data/lib/thrift/transport/httpclient.rb +0 -29
- data/lib/thrift/transport/thttpclient.rb +0 -2
- data/lib/thrift/transport/tsocket.rb +0 -2
- data/lib/thrift/transport/ttransport.rb +0 -2
- data/lib/thrift/transport/unixsocket.rb +0 -58
- data/lib/thrift/transport.rb +0 -319
- data/spec/backwards_compatibility_spec.rb +0 -136
- data/spec/binaryprotocolaccelerated_spec.rb +0 -101
- data/spec/deprecation_spec.rb +0 -443
- data/spec/gen-rb/NonblockingService.rb +0 -268
- data/spec/gen-rb/ThriftSpec_constants.rb +0 -11
- data/spec/gen-rb/ThriftSpec_types.rb +0 -134
- data/spec/httpclient_spec.rb +0 -31
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
CHANGELOG
|
|
2
|
-
COPYING
|
|
3
|
-
LICENSE
|
|
4
|
-
Makefile.am
|
|
5
2
|
Manifest
|
|
6
|
-
README
|
|
7
3
|
Rakefile
|
|
8
|
-
|
|
4
|
+
README
|
|
5
|
+
setup.rb
|
|
9
6
|
benchmark/benchmark.rb
|
|
7
|
+
benchmark/Benchmark.thrift
|
|
10
8
|
benchmark/client.rb
|
|
11
|
-
benchmark/gen-rb/BenchmarkService.rb
|
|
12
|
-
benchmark/gen-rb/Benchmark_constants.rb
|
|
13
|
-
benchmark/gen-rb/Benchmark_types.rb
|
|
14
9
|
benchmark/server.rb
|
|
15
10
|
benchmark/thin_server.rb
|
|
16
11
|
ext/binary_protocol_accelerated.c
|
|
17
12
|
ext/binary_protocol_accelerated.h
|
|
13
|
+
ext/compact_protocol.c
|
|
14
|
+
ext/compact_protocol.h
|
|
18
15
|
ext/constants.h
|
|
19
16
|
ext/extconf.rb
|
|
17
|
+
ext/macros.h
|
|
20
18
|
ext/memory_buffer.c
|
|
21
19
|
ext/memory_buffer.h
|
|
22
20
|
ext/protocol.c
|
|
@@ -26,53 +24,58 @@ ext/struct.h
|
|
|
26
24
|
ext/thrift_native.c
|
|
27
25
|
lib/thrift.rb
|
|
28
26
|
lib/thrift/client.rb
|
|
29
|
-
lib/thrift/
|
|
27
|
+
lib/thrift/core_ext.rb
|
|
30
28
|
lib/thrift/exceptions.rb
|
|
31
29
|
lib/thrift/processor.rb
|
|
32
|
-
lib/thrift/protocol.rb
|
|
33
|
-
lib/thrift/protocol/binaryprotocol.rb
|
|
34
|
-
lib/thrift/protocol/binaryprotocolaccelerated.rb
|
|
35
|
-
lib/thrift/protocol/tbinaryprotocol.rb
|
|
36
|
-
lib/thrift/protocol/tprotocol.rb
|
|
37
|
-
lib/thrift/serializer.rb
|
|
38
|
-
lib/thrift/server.rb
|
|
39
|
-
lib/thrift/server/httpserver.rb
|
|
40
|
-
lib/thrift/server/nonblockingserver.rb
|
|
41
|
-
lib/thrift/server/thttpserver.rb
|
|
42
|
-
lib/thrift/server/tserver.rb
|
|
43
30
|
lib/thrift/struct.rb
|
|
44
|
-
lib/thrift/
|
|
45
|
-
lib/thrift/transport.rb
|
|
46
|
-
lib/thrift/transport/httpclient.rb
|
|
47
|
-
lib/thrift/transport/socket.rb
|
|
48
|
-
lib/thrift/transport/thttpclient.rb
|
|
49
|
-
lib/thrift/transport/tsocket.rb
|
|
50
|
-
lib/thrift/transport/ttransport.rb
|
|
51
|
-
lib/thrift/transport/unixsocket.rb
|
|
31
|
+
lib/thrift/thrift_native.rb
|
|
52
32
|
lib/thrift/types.rb
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
33
|
+
lib/thrift/core_ext/fixnum.rb
|
|
34
|
+
lib/thrift/protocol/base_protocol.rb
|
|
35
|
+
lib/thrift/protocol/binary_protocol.rb
|
|
36
|
+
lib/thrift/protocol/binary_protocol_accelerated.rb
|
|
37
|
+
lib/thrift/protocol/compact_protocol.rb
|
|
38
|
+
lib/thrift/serializer/deserializer.rb
|
|
39
|
+
lib/thrift/serializer/serializer.rb
|
|
40
|
+
lib/thrift/server/base_server.rb
|
|
41
|
+
lib/thrift/server/mongrel_http_server.rb
|
|
42
|
+
lib/thrift/server/nonblocking_server.rb
|
|
43
|
+
lib/thrift/server/simple_server.rb
|
|
44
|
+
lib/thrift/server/thread_pool_server.rb
|
|
45
|
+
lib/thrift/server/threaded_server.rb
|
|
46
|
+
lib/thrift/transport/base_server_transport.rb
|
|
47
|
+
lib/thrift/transport/base_transport.rb
|
|
48
|
+
lib/thrift/transport/buffered_transport.rb
|
|
49
|
+
lib/thrift/transport/framed_transport.rb
|
|
50
|
+
lib/thrift/transport/http_client_transport.rb
|
|
51
|
+
lib/thrift/transport/io_stream_transport.rb
|
|
52
|
+
lib/thrift/transport/memory_buffer_transport.rb
|
|
53
|
+
lib/thrift/transport/server_socket.rb
|
|
54
|
+
lib/thrift/transport/socket.rb
|
|
55
|
+
lib/thrift/transport/unix_server_socket.rb
|
|
56
|
+
lib/thrift/transport/unix_socket.rb
|
|
57
|
+
script/proto_benchmark.rb
|
|
58
|
+
script/read_struct.rb
|
|
59
|
+
script/write_struct.rb
|
|
60
|
+
spec/base_protocol_spec.rb
|
|
61
|
+
spec/base_transport_spec.rb
|
|
62
|
+
spec/binary_protocol_accelerated_spec.rb
|
|
63
|
+
spec/binary_protocol_spec.rb
|
|
64
|
+
spec/binary_protocol_spec_shared.rb
|
|
59
65
|
spec/client_spec.rb
|
|
60
|
-
spec/
|
|
66
|
+
spec/compact_protocol_spec.rb
|
|
61
67
|
spec/exception_spec.rb
|
|
62
|
-
spec/
|
|
63
|
-
spec/
|
|
64
|
-
spec/
|
|
65
|
-
spec/httpclient_spec.rb
|
|
66
|
-
spec/httpserver_spec.rb
|
|
67
|
-
spec/nonblockingserver_spec.rb
|
|
68
|
+
spec/http_client_spec.rb
|
|
69
|
+
spec/mongrel_http_server_spec.rb
|
|
70
|
+
spec/nonblocking_server_spec.rb
|
|
68
71
|
spec/processor_spec.rb
|
|
69
|
-
spec/protocol_spec.rb
|
|
70
72
|
spec/serializer_spec.rb
|
|
73
|
+
spec/server_socket_spec.rb
|
|
71
74
|
spec/server_spec.rb
|
|
72
75
|
spec/socket_spec.rb
|
|
73
76
|
spec/socket_spec_shared.rb
|
|
74
77
|
spec/spec_helper.rb
|
|
75
78
|
spec/struct_spec.rb
|
|
76
|
-
spec/
|
|
79
|
+
spec/ThriftSpec.thrift
|
|
77
80
|
spec/types_spec.rb
|
|
78
|
-
spec/
|
|
81
|
+
spec/unix_socket_spec.rb
|
data/README
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
Thrift Ruby Software Library
|
|
2
|
-
by Kevin Ballard, Kevin Clark, Mark Slee
|
|
3
2
|
http://incubator.apache.org/thrift/
|
|
4
3
|
|
|
4
|
+
== LICENSE:
|
|
5
|
+
|
|
6
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
7
|
+
or more contributor license agreements. See the NOTICE file
|
|
8
|
+
distributed with this work for additional information
|
|
9
|
+
regarding copyright ownership. The ASF licenses this file
|
|
10
|
+
to you under the Apache License, Version 2.0 (the
|
|
11
|
+
"License"); you may not use this file except in compliance
|
|
12
|
+
with the License. You may obtain a copy of the License at
|
|
13
|
+
|
|
14
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
|
|
16
|
+
Unless required by applicable law or agreed to in writing,
|
|
17
|
+
software distributed under the License is distributed on an
|
|
18
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
19
|
+
KIND, either express or implied. See the License for the
|
|
20
|
+
specific language governing permissions and limitations
|
|
21
|
+
under the License.
|
|
22
|
+
|
|
5
23
|
== DESCRIPTION:
|
|
6
24
|
|
|
7
25
|
Thrift is a strongly-typed language-agnostic RPC system.
|
|
@@ -23,8 +41,3 @@ thrift software package.
|
|
|
23
41
|
This section should get written by someone with the time and inclination.
|
|
24
42
|
In the meantime, look at existing code, such as the benchmark or the tutorial
|
|
25
43
|
in the full thrift distribution.
|
|
26
|
-
|
|
27
|
-
== LICENSE:
|
|
28
|
-
|
|
29
|
-
Thrift is distributed under the Apache Software License.
|
|
30
|
-
Please see the included LICENSE file.
|
data/Rakefile
CHANGED
|
@@ -79,7 +79,7 @@ begin
|
|
|
79
79
|
Echoe.new('thrift') do |p|
|
|
80
80
|
p.author = ['Kevin Ballard', 'Kevin Clark', 'Mark Slee', 'Evan Weaver']
|
|
81
81
|
p.project = "fauna"
|
|
82
|
-
p.summary = "Ruby libraries for Thrift
|
|
82
|
+
p.summary = "Ruby libraries for Thrift, with fixes."
|
|
83
83
|
p.include_rakefile = true
|
|
84
84
|
p.url = "http://blog.evanweaver.com/files/doc/fauna/thrift/"
|
|
85
85
|
p.docs_host = "blog.evanweaver.com:~/www/bax/public/files/doc/"
|
data/benchmark/Benchmark.thrift
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
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
|
+
|
|
1
20
|
namespace rb ThriftBenchmark
|
|
2
21
|
|
|
3
22
|
service BenchmarkService {
|
data/benchmark/benchmark.rb
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
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
|
+
|
|
1
20
|
require 'rubygems'
|
|
2
21
|
$:.unshift File.dirname(__FILE__) + '/../lib'
|
|
3
22
|
require 'thrift'
|
|
4
|
-
require 'thrift/server/nonblockingserver'
|
|
5
|
-
require 'thrift/transport/unixsocket'
|
|
6
23
|
require 'stringio'
|
|
7
24
|
|
|
8
25
|
HOST = '127.0.0.1'
|
|
@@ -214,7 +231,7 @@ class BenchmarkManager
|
|
|
214
231
|
}
|
|
215
232
|
|
|
216
233
|
def tabulate(fmt, *labels_and_values)
|
|
217
|
-
labels = labels_and_values.map { |
|
|
234
|
+
labels = labels_and_values.map { |l| Array === l ? l.first : l }
|
|
218
235
|
label_width = labels.inject(0) { |w,l| l.size > w ? l.size : w }
|
|
219
236
|
labels_and_values.each do |(l,v)|
|
|
220
237
|
f = fmt
|
data/benchmark/client.rb
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
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
|
+
|
|
1
20
|
$:.unshift File.dirname(__FILE__) + '/../lib'
|
|
2
21
|
require 'thrift'
|
|
3
|
-
require 'thrift/server/nonblockingserver'
|
|
4
22
|
$:.unshift File.dirname(__FILE__) + "/gen-rb"
|
|
5
|
-
require '
|
|
23
|
+
require 'benchmark_service'
|
|
6
24
|
|
|
7
25
|
class Client
|
|
8
26
|
def initialize(host, port, clients_per_process, calls_per_client, log_exceptions)
|
data/benchmark/server.rb
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
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
|
+
|
|
1
20
|
$:.unshift File.dirname(__FILE__) + '/../lib'
|
|
2
21
|
require 'thrift'
|
|
3
|
-
require 'thrift/server/nonblockingserver'
|
|
4
22
|
$:.unshift File.dirname(__FILE__) + "/gen-rb"
|
|
5
|
-
require '
|
|
23
|
+
require 'benchmark_service'
|
|
6
24
|
|
|
7
25
|
module Server
|
|
8
26
|
include Thrift
|
|
@@ -22,8 +40,8 @@ module Server
|
|
|
22
40
|
handler = BenchmarkHandler.new
|
|
23
41
|
processor = ThriftBenchmark::BenchmarkService::Processor.new(handler)
|
|
24
42
|
transport = ServerSocket.new(host, port)
|
|
25
|
-
|
|
26
|
-
args = [processor, transport,
|
|
43
|
+
transport_factory = FramedTransportFactory.new
|
|
44
|
+
args = [processor, transport, transport_factory, nil, 20]
|
|
27
45
|
if serverClass == NonblockingServer
|
|
28
46
|
logger = Logger.new(STDERR)
|
|
29
47
|
logger.level = Logger::WARN
|
data/benchmark/thin_server.rb
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
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
|
+
|
|
1
20
|
$:.unshift File.dirname(__FILE__) + '/../lib'
|
|
2
21
|
require 'thrift'
|
|
3
|
-
require 'thrift/server/nonblockingserver'
|
|
4
22
|
$:.unshift File.dirname(__FILE__) + "/gen-rb"
|
|
5
|
-
require '
|
|
23
|
+
require 'benchmark_service'
|
|
6
24
|
HOST = 'localhost'
|
|
7
25
|
PORT = 42587
|
|
8
26
|
|
|
@@ -20,7 +38,7 @@ end
|
|
|
20
38
|
handler = BenchmarkHandler.new
|
|
21
39
|
processor = ThriftBenchmark::BenchmarkService::Processor.new(handler)
|
|
22
40
|
transport = Thrift::ServerSocket.new(HOST, PORT)
|
|
23
|
-
|
|
41
|
+
transport_factory = Thrift::FramedTransportFactory.new
|
|
24
42
|
logger = Logger.new(STDERR)
|
|
25
43
|
logger.level = Logger::WARN
|
|
26
|
-
Thrift::NonblockingServer.new(processor, transport,
|
|
44
|
+
Thrift::NonblockingServer.new(processor, transport, transport_factory, nil, 20, logger).serve
|
|
@@ -1,14 +1,28 @@
|
|
|
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
|
+
|
|
1
20
|
#include <ruby.h>
|
|
2
21
|
#include <stdbool.h>
|
|
3
22
|
#include <stdint.h>
|
|
4
23
|
#include <constants.h>
|
|
5
24
|
#include <struct.h>
|
|
6
|
-
|
|
7
|
-
#define GET_TRANSPORT(obj) rb_ivar_get(obj, transport_ivar_id)
|
|
8
|
-
#define GET_STRICT_READ(obj) rb_ivar_get(obj, strict_read_ivar_id)
|
|
9
|
-
#define GET_STRICT_WRITE(obj) rb_ivar_get(obj, strict_write_ivar_id)
|
|
10
|
-
#define WRITE(obj, data, length) rb_funcall(obj, write_method_id, 1, rb_str_new(data, length))
|
|
11
|
-
#define CHECK_NIL(obj) if (NIL_P(obj)) { rb_raise(rb_eStandardError, "nil argument not allowed!");}
|
|
25
|
+
#include "macros.h"
|
|
12
26
|
|
|
13
27
|
VALUE rb_thrift_binary_proto_native_qmark(VALUE self) {
|
|
14
28
|
return Qtrue;
|
|
@@ -62,7 +76,7 @@ static void write_i64_direct(VALUE trans, int64_t value) {
|
|
|
62
76
|
}
|
|
63
77
|
|
|
64
78
|
static void write_string_direct(VALUE trans, VALUE str) {
|
|
65
|
-
write_i32_direct(trans,
|
|
79
|
+
write_i32_direct(trans, RSTRING_LEN(str));
|
|
66
80
|
rb_funcall(trans, write_method_id, 1, str);
|
|
67
81
|
}
|
|
68
82
|
|
|
@@ -108,7 +122,7 @@ VALUE rb_thrift_binary_proto_write_message_begin(VALUE self, VALUE name, VALUE t
|
|
|
108
122
|
write_i32_direct(trans, FIX2INT(seqid));
|
|
109
123
|
} else {
|
|
110
124
|
write_string_direct(trans, name);
|
|
111
|
-
write_byte_direct(trans, type);
|
|
125
|
+
write_byte_direct(trans, FIX2INT(type));
|
|
112
126
|
write_i32_direct(trans, FIX2INT(seqid));
|
|
113
127
|
}
|
|
114
128
|
|
|
@@ -186,7 +200,7 @@ VALUE rb_thrift_binary_proto_write_double(VALUE self, VALUE dub) {
|
|
|
186
200
|
double f;
|
|
187
201
|
int64_t t;
|
|
188
202
|
} transfer;
|
|
189
|
-
transfer.f =
|
|
203
|
+
transfer.f = RFLOAT_VALUE(rb_Float(dub));
|
|
190
204
|
write_i64_direct(GET_TRANSPORT(self), transfer.t);
|
|
191
205
|
|
|
192
206
|
return Qnil;
|
|
@@ -195,8 +209,6 @@ VALUE rb_thrift_binary_proto_write_double(VALUE self, VALUE dub) {
|
|
|
195
209
|
VALUE rb_thrift_binary_proto_write_string(VALUE self, VALUE str) {
|
|
196
210
|
CHECK_NIL(str);
|
|
197
211
|
VALUE trans = GET_TRANSPORT(self);
|
|
198
|
-
// write_i32_direct(trans, RSTRING(str)->len);
|
|
199
|
-
// rb_funcall(trans, write_method_id, 1, str);
|
|
200
212
|
write_string_direct(trans, str);
|
|
201
213
|
return Qnil;
|
|
202
214
|
}
|
|
@@ -205,28 +217,27 @@ VALUE rb_thrift_binary_proto_write_string(VALUE self, VALUE str) {
|
|
|
205
217
|
// interface reading methods
|
|
206
218
|
//---------------------------------------
|
|
207
219
|
|
|
208
|
-
#define READ(obj, length) rb_funcall(GET_TRANSPORT(obj), read_method_id, 1, INT2FIX(length))
|
|
209
|
-
|
|
210
220
|
VALUE rb_thrift_binary_proto_read_string(VALUE self);
|
|
211
221
|
VALUE rb_thrift_binary_proto_read_byte(VALUE self);
|
|
212
222
|
VALUE rb_thrift_binary_proto_read_i32(VALUE self);
|
|
213
223
|
VALUE rb_thrift_binary_proto_read_i16(VALUE self);
|
|
214
224
|
|
|
215
225
|
static char read_byte_direct(VALUE self) {
|
|
216
|
-
|
|
226
|
+
VALUE buf = READ(self, 1);
|
|
227
|
+
return RSTRING_PTR(buf)[0];
|
|
217
228
|
}
|
|
218
229
|
|
|
219
230
|
static int16_t read_i16_direct(VALUE self) {
|
|
220
231
|
VALUE buf = READ(self, 2);
|
|
221
|
-
return (int16_t)(((uint8_t)(
|
|
232
|
+
return (int16_t)(((uint8_t)(RSTRING_PTR(buf)[1])) | ((uint16_t)((RSTRING_PTR(buf)[0]) << 8)));
|
|
222
233
|
}
|
|
223
234
|
|
|
224
235
|
static int32_t read_i32_direct(VALUE self) {
|
|
225
236
|
VALUE buf = READ(self, 4);
|
|
226
|
-
return ((uint8_t)(
|
|
227
|
-
(((uint8_t)(
|
|
228
|
-
(((uint8_t)(
|
|
229
|
-
(((uint8_t)(
|
|
237
|
+
return ((uint8_t)(RSTRING_PTR(buf)[3])) |
|
|
238
|
+
(((uint8_t)(RSTRING_PTR(buf)[2])) << 8) |
|
|
239
|
+
(((uint8_t)(RSTRING_PTR(buf)[1])) << 16) |
|
|
240
|
+
(((uint8_t)(RSTRING_PTR(buf)[0])) << 24);
|
|
230
241
|
}
|
|
231
242
|
|
|
232
243
|
static int64_t read_i64_direct(VALUE self) {
|
|
@@ -289,7 +300,7 @@ VALUE rb_thrift_binary_proto_read_message_begin(VALUE self) {
|
|
|
289
300
|
rb_exc_raise(get_protocol_exception(INT2FIX(BAD_VERSION), rb_str_new2("No version identifier, old protocol client?")));
|
|
290
301
|
}
|
|
291
302
|
name = READ(self, version);
|
|
292
|
-
type =
|
|
303
|
+
type = read_byte_direct(self);
|
|
293
304
|
seqid = rb_thrift_binary_proto_read_i32(self);
|
|
294
305
|
}
|
|
295
306
|
|
|
@@ -325,7 +336,7 @@ VALUE rb_thrift_binary_proto_read_set_begin(VALUE self) {
|
|
|
325
336
|
|
|
326
337
|
VALUE rb_thrift_binary_proto_read_bool(VALUE self) {
|
|
327
338
|
char byte = read_byte_direct(self);
|
|
328
|
-
return byte
|
|
339
|
+
return byte != 0 ? Qtrue : Qfalse;
|
|
329
340
|
}
|
|
330
341
|
|
|
331
342
|
VALUE rb_thrift_binary_proto_read_byte(VALUE self) {
|
|
@@ -1 +1,20 @@
|
|
|
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
|
+
|
|
1
20
|
void Init_binary_protocol_accelerated();
|