protobuf 1.4.2 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Rakefile +7 -7
- data/bin/rpc_server +2 -188
- data/bin/rprotoc +44 -38
- data/examples/addressbook.pb.rb +2 -2
- data/ext/Makefile +11 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/code_generator.h +142 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/command_line_interface.h +318 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_enum.h +99 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_enum_field.h +103 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_extension.h +85 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_field.h +167 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_file.h +98 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_generator.h +72 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_helpers.h +159 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_message.h +170 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_message_field.h +102 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +103 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_service.h +118 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_string_field.h +104 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h +2721 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/importer.h +303 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_enum.h +84 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_enum_field.h +121 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_extension.h +77 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_field.h +108 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_file.h +101 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_generator.h +72 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_helpers.h +213 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_message.h +109 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_message_field.h +134 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_primitive_field.h +121 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_service.h +113 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_string_field.h +120 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/mock_code_generator.h +113 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/package_info.h +64 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/parser.h +434 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/plugin.h +73 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/plugin.pb.h +790 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/python/python_generator.h +156 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/subprocess.h +108 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/zip_writer.h +93 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/descriptor.h +1367 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/descriptor.pb.h +5223 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/descriptor_database.h +366 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/dynamic_message.h +136 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/extension_set.h +904 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/generated_message_reflection.h +424 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/generated_message_util.h +82 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/coded_stream.h +1102 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/coded_stream_inl.h +64 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/gzip_stream.h +207 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/package_info.h +54 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/printer.h +136 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/tokenizer.h +313 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/zero_copy_stream.h +238 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/zero_copy_stream_impl.h +357 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/zero_copy_stream_impl_lite.h +340 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/message.h +692 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/message_lite.h +239 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/package_info.h +64 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/reflection_ops.h +80 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/repeated_field.h +1295 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/service.h +291 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/common.h +1211 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/hash.h +220 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/map-util.h +119 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/once.h +123 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/stl_util-inl.h +121 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/strutil.h +457 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/substitute.h +170 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/test_util.h +174 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/test_util_lite.h +101 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/testing/file.h +83 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/testing/googletest.h +98 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/text_format.h +285 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest.pb.h +11915 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_custom_options.pb.h +2895 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_embed_optimize_for.pb.h +211 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_empty.pb.h +56 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_import.pb.h +188 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_import_lite.pb.h +151 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_lite.pb.h +4752 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_lite_imports_nonlite.pb.h +150 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_mset.pb.h +816 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_no_generic_services.pb.h +197 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_optimize_for.pb.h +403 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unknown_field_set.h +268 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/wire_format.h +304 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/wire_format_lite.h +620 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/wire_format_lite_inl.h +774 -0
- data/ext/ruby_generator/RubyGenerator.cpp +435 -0
- data/ext/ruby_generator/RubyGenerator.h +180 -0
- data/ext/ruby_generator/extconf.rb +24 -0
- data/lib/protobuf.rb +55 -33
- data/lib/protobuf/cli.rb +176 -0
- data/lib/protobuf/common/logger.rb +11 -11
- data/lib/protobuf/{message/enum.rb → enum.rb} +0 -10
- data/lib/protobuf/evented.rb +22 -0
- data/lib/protobuf/field.rb +57 -0
- data/lib/protobuf/field/base_field.rb +210 -0
- data/lib/protobuf/field/bool_field.rb +24 -0
- data/lib/protobuf/field/bytes_field.rb +38 -0
- data/lib/protobuf/field/double_field.rb +19 -0
- data/lib/protobuf/field/enum_field.rb +58 -0
- data/lib/protobuf/field/extension_fields.rb +24 -0
- data/lib/protobuf/field/field_array.rb +55 -0
- data/lib/protobuf/field/fixed32_field.rb +19 -0
- data/lib/protobuf/field/fixed64_field.rb +22 -0
- data/lib/protobuf/field/float_field.rb +29 -0
- data/lib/protobuf/field/int32_field.rb +10 -0
- data/lib/protobuf/field/int64_field.rb +10 -0
- data/lib/protobuf/field/integer_field.rb +19 -0
- data/lib/protobuf/field/message_field.rb +51 -0
- data/lib/protobuf/field/sfixed32_field.rb +21 -0
- data/lib/protobuf/field/sfixed64_field.rb +24 -0
- data/lib/protobuf/field/signed_integer_field.rb +23 -0
- data/lib/protobuf/field/sint32_field.rb +10 -0
- data/lib/protobuf/field/sint64_field.rb +10 -0
- data/lib/protobuf/field/string_field.rb +14 -0
- data/lib/protobuf/field/uint32_field.rb +10 -0
- data/lib/protobuf/field/uint64_field.rb +10 -0
- data/lib/protobuf/field/varint_field.rb +63 -0
- data/lib/protobuf/message.rb +376 -0
- data/lib/protobuf/message/message.rb +1 -475
- data/lib/protobuf/rpc/buffer.rb +1 -1
- data/lib/protobuf/rpc/client.rb +26 -26
- data/lib/protobuf/rpc/connector.rb +15 -14
- data/lib/protobuf/rpc/connectors/eventmachine.rb +13 -13
- data/lib/protobuf/rpc/rpc.pb.rb +39 -28
- data/lib/protobuf/rpc/server.rb +7 -28
- data/lib/protobuf/rpc/servers/evented_runner.rb +15 -15
- data/lib/protobuf/rpc/servers/socket/server.rb +2 -1
- data/lib/protobuf/rpc/servers/socket_runner.rb +5 -6
- data/lib/protobuf/rpc/servers/zmq_runner.rb +4 -5
- data/lib/protobuf/socket.rb +22 -0
- data/lib/protobuf/version.rb +2 -1
- data/lib/protobuf/zmq.rb +21 -0
- data/proto/rpc.pb.rb +48 -0
- data/protobuf.gemspec +14 -6
- data/spec/benchmark/tasks.rb +42 -23
- data/spec/functional/evented_server_spec.rb +2 -0
- data/spec/functional/socket_server_spec.rb +22 -26
- data/spec/functional/zmq_server_spec.rb +22 -26
- data/spec/lib/protobuf/cli_spec.rb +182 -0
- data/spec/{unit → lib/protobuf}/common/logger_spec.rb +0 -0
- data/spec/{unit → lib/protobuf/message}/enum_spec.rb +0 -0
- data/spec/{unit → lib/protobuf/message}/message_spec.rb +0 -0
- data/spec/{unit → lib/protobuf}/rpc/client_spec.rb +6 -4
- data/spec/lib/protobuf/rpc/connector_spec.rb +41 -0
- data/spec/{unit → lib/protobuf}/rpc/connectors/base_spec.rb +18 -18
- data/spec/{unit → lib/protobuf}/rpc/connectors/common_spec.rb +20 -20
- data/spec/{unit → lib/protobuf}/rpc/connectors/socket_spec.rb +9 -8
- data/spec/{unit → lib/protobuf}/rpc/connectors/zmq_spec.rb +1 -1
- data/spec/{unit → lib/protobuf}/rpc/servers/evented_server_spec.rb +4 -4
- data/spec/{unit → lib/protobuf}/rpc/servers/socket_server_spec.rb +11 -23
- data/spec/{unit → lib/protobuf}/rpc/servers/zmq/broker_spec.rb +5 -0
- data/spec/{unit → lib/protobuf}/rpc/servers/zmq/server_spec.rb +5 -0
- data/spec/{unit → lib/protobuf}/rpc/servers/zmq/util_spec.rb +5 -0
- data/spec/{unit → lib/protobuf}/rpc/servers/zmq/worker_spec.rb +5 -0
- data/spec/{unit → lib/protobuf}/rpc/service_spec.rb +0 -0
- data/spec/proto/test.pb.rb +48 -25
- data/spec/spec_helper.rb +9 -15
- data/spec/support/all.rb +7 -0
- data/spec/{helper → support}/server.rb +5 -7
- data/spec/{helper → support}/silent_constants.rb +4 -0
- data/spec/support/test_app_file.rb +2 -0
- data/spec/{helper → support}/tolerance_matcher.rb +0 -0
- data/test/proto/types.pb.rb +1 -1
- data/test/test_addressbook.rb +1 -1
- data/test/test_enum_value.rb +1 -1
- data/test/test_standard_message.rb +1 -1
- metadata +243 -107
- data/lib/protobuf/common/util.rb +0 -59
- data/lib/protobuf/compiler/compiler.rb +0 -52
- data/lib/protobuf/compiler/nodes.rb +0 -323
- data/lib/protobuf/compiler/proto.y +0 -216
- data/lib/protobuf/compiler/proto2.ebnf +0 -79
- data/lib/protobuf/compiler/proto_parser.rb +0 -1425
- data/lib/protobuf/compiler/template/rpc_service_implementation.erb +0 -42
- data/lib/protobuf/compiler/visitors.rb +0 -282
- data/lib/protobuf/descriptor/descriptor.proto +0 -286
- data/lib/protobuf/descriptor/descriptor.rb +0 -55
- data/lib/protobuf/descriptor/descriptor_builder.rb +0 -143
- data/lib/protobuf/descriptor/descriptor_proto.rb +0 -138
- data/lib/protobuf/descriptor/enum_descriptor.rb +0 -33
- data/lib/protobuf/descriptor/field_descriptor.rb +0 -49
- data/lib/protobuf/descriptor/file_descriptor.rb +0 -37
- data/lib/protobuf/message/field.rb +0 -684
- data/lib/protobuf/message/protoable.rb +0 -38
- data/spec/helper/all.rb +0 -7
- data/spec/unit/common/util_spec.rb +0 -17
- data/spec/unit/rpc/connector_spec.rb +0 -31
- data/spec/unit/rpc/connectors/eventmachine_client_spec.rb +0 -32
- data/spec/unit/rpc/connectors/eventmachine_spec.rb +0 -0
- data/test/check_unbuild.rb +0 -30
- data/test/test_compiler.rb +0 -325
- data/test/test_descriptor.rb +0 -122
@@ -52,6 +52,7 @@ module Protobuf
|
|
52
52
|
@threads = []
|
53
53
|
@thread_threshold = thread_threshold
|
54
54
|
@server = ::TCPServer.new(host, port)
|
55
|
+
raise "blah" if @server.closed?
|
55
56
|
@server.listen(backlog)
|
56
57
|
@working = []
|
57
58
|
@listen_fds = [@server]
|
@@ -90,7 +91,7 @@ module Protobuf
|
|
90
91
|
raise
|
91
92
|
rescue
|
92
93
|
# Closing the server causes the loop to raise an exception here
|
93
|
-
raise if running?
|
94
|
+
raise #if running?
|
94
95
|
end
|
95
96
|
|
96
97
|
def self.running?
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module Protobuf
|
2
2
|
module Rpc
|
3
|
-
class SocketRunner
|
3
|
+
class SocketRunner
|
4
4
|
|
5
5
|
def self.stop
|
6
|
-
::Protobuf::Rpc::Socket::Server.stop
|
7
|
-
::Protobuf::Logger.info { 'Shutdown complete' }
|
6
|
+
::Protobuf::Rpc::Socket::Server.stop
|
8
7
|
end
|
9
8
|
|
10
9
|
def self.run(server)
|
11
|
-
|
12
|
-
|
13
|
-
when server.is_a?(OpenStruct) then
|
10
|
+
server_config = case
|
11
|
+
when server.is_a?(OpenStruct) then
|
14
12
|
server.marshal_dump
|
15
13
|
when server.is_a?(Hash) then
|
16
14
|
server
|
@@ -20,6 +18,7 @@ module Protobuf
|
|
20
18
|
raise "Cannot parser Socket Server - server options"
|
21
19
|
end
|
22
20
|
|
21
|
+
yield if block_given?
|
23
22
|
::Protobuf::Rpc::Socket::Server.run(server_config)
|
24
23
|
end
|
25
24
|
|
@@ -3,14 +3,12 @@ module Protobuf
|
|
3
3
|
class ZmqRunner
|
4
4
|
|
5
5
|
def self.stop
|
6
|
-
Protobuf::Rpc::Zmq::Server.stop
|
7
|
-
Protobuf::Logger.info('Shutdown complete')
|
6
|
+
Protobuf::Rpc::Zmq::Server.stop
|
8
7
|
end
|
9
8
|
|
10
9
|
def self.run(server)
|
11
|
-
|
12
|
-
|
13
|
-
when server.is_a?(OpenStruct) then
|
10
|
+
server_config = case
|
11
|
+
when server.is_a?(OpenStruct) then
|
14
12
|
server.marshal_dump
|
15
13
|
when server.respond_to?(:to_hash) then
|
16
14
|
server.to_hash
|
@@ -18,6 +16,7 @@ module Protobuf
|
|
18
16
|
raise "Cannot parser Zmq Server - server options"
|
19
17
|
end
|
20
18
|
|
19
|
+
yield if block_given?
|
21
20
|
Protobuf::Rpc::Zmq::Server.run(server_config)
|
22
21
|
end
|
23
22
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
##
|
2
|
+
## Socket Mode
|
3
|
+
##
|
4
|
+
#
|
5
|
+
# Require this file if you wish to run your server and/or client RPC
|
6
|
+
# with the raw socket handlers. This is the default run mode for bin/rpc_server.
|
7
|
+
#
|
8
|
+
# To run with rpc_server either omit any mode switches, or explicitly pass `socket`:
|
9
|
+
#
|
10
|
+
# rpc_server myapp.rb
|
11
|
+
# rpc_server --socket myapp.rb
|
12
|
+
#
|
13
|
+
# To run for client-side only override the require in your Gemfile:
|
14
|
+
#
|
15
|
+
# gem 'protobuf', :require => 'protobuf/socket'
|
16
|
+
#
|
17
|
+
require 'protobuf'
|
18
|
+
::Protobuf.connector_type = :socket
|
19
|
+
|
20
|
+
require 'protobuf/rpc/servers/socket/server'
|
21
|
+
require 'protobuf/rpc/connectors/socket'
|
22
|
+
|
data/lib/protobuf/version.rb
CHANGED
data/lib/protobuf/zmq.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
##
|
2
|
+
## ZMQ Mode
|
3
|
+
##
|
4
|
+
#
|
5
|
+
# Require this file if you wish to run your server and/or client RPC
|
6
|
+
# with the ZeroMQ handlers.
|
7
|
+
#
|
8
|
+
# To run with rpc_server specify the switch `zmq`:
|
9
|
+
#
|
10
|
+
# rpc_server --zmq myapp.rb
|
11
|
+
#
|
12
|
+
# To run for client-side only override the require in your Gemfile:
|
13
|
+
#
|
14
|
+
# gem 'protobuf', :require => 'protobuf/zmq'
|
15
|
+
#
|
16
|
+
require 'protobuf'
|
17
|
+
Protobuf.connector_type = :zmq
|
18
|
+
|
19
|
+
require 'ffi-rzmq'
|
20
|
+
require 'protobuf/rpc/servers/zmq/server'
|
21
|
+
require 'protobuf/rpc/connectors/zmq'
|
data/proto/rpc.pb.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
##
|
2
|
+
# This file is auto-generated. DO NOT EDIT!
|
3
|
+
#
|
4
|
+
require 'protobuf/message'
|
5
|
+
|
6
|
+
module Protobuf
|
7
|
+
module Socketrpc
|
8
|
+
##
|
9
|
+
# Enum Classes
|
10
|
+
#
|
11
|
+
class ErrorReason < ::Protobuf::Enum; end
|
12
|
+
|
13
|
+
##
|
14
|
+
# Message Classes
|
15
|
+
#
|
16
|
+
class Request < ::Protobuf::Message; end
|
17
|
+
class Response < ::Protobuf::Message; end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Enum Values
|
21
|
+
#
|
22
|
+
::Protobuf::Socketrpc::ErrorReason.define :BAD_REQUEST_DATA, 0
|
23
|
+
::Protobuf::Socketrpc::ErrorReason.define :BAD_REQUEST_PROTO, 1
|
24
|
+
::Protobuf::Socketrpc::ErrorReason.define :SERVICE_NOT_FOUND, 2
|
25
|
+
::Protobuf::Socketrpc::ErrorReason.define :METHOD_NOT_FOUND, 3
|
26
|
+
::Protobuf::Socketrpc::ErrorReason.define :RPC_ERROR, 4
|
27
|
+
::Protobuf::Socketrpc::ErrorReason.define :RPC_FAILED, 5
|
28
|
+
::Protobuf::Socketrpc::ErrorReason.define :INVALID_REQUEST_PROTO, 6
|
29
|
+
::Protobuf::Socketrpc::ErrorReason.define :BAD_RESPONSE_PROTO, 7
|
30
|
+
::Protobuf::Socketrpc::ErrorReason.define :UNKNOWN_HOST, 8
|
31
|
+
::Protobuf::Socketrpc::ErrorReason.define :IO_ERROR, 9
|
32
|
+
|
33
|
+
|
34
|
+
##
|
35
|
+
# Message Fields
|
36
|
+
#
|
37
|
+
::Protobuf::Socketrpc::Request.required(::Protobuf::Field::StringField, :service_name, 1)
|
38
|
+
::Protobuf::Socketrpc::Request.required(::Protobuf::Field::StringField, :method_name, 2)
|
39
|
+
::Protobuf::Socketrpc::Request.required(::Protobuf::Field::BytesField, :request_proto, 3)
|
40
|
+
|
41
|
+
::Protobuf::Socketrpc::Response.optional(::Protobuf::Field::BytesField, :response_proto, 1)
|
42
|
+
::Protobuf::Socketrpc::Response.optional(::Protobuf::Field::StringField, :error, 2)
|
43
|
+
::Protobuf::Socketrpc::Response.optional(::Protobuf::Field::BoolField, :callback, 3, :default => false)
|
44
|
+
::Protobuf::Socketrpc::Response.optional(::Protobuf::Socketrpc::ErrorReason, :error_reason, 4)
|
45
|
+
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
data/protobuf.gemspec
CHANGED
@@ -18,15 +18,23 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
s.add_dependency 'ffi-rzmq'
|
21
|
+
unless ENV['WITHOUT_PROTO_COMPILER']
|
22
|
+
s.extensions << File.join('ext', 'ruby_generator', 'extconf.rb')
|
23
|
+
end
|
25
24
|
|
26
|
-
s.
|
25
|
+
s.add_dependency 'activesupport'
|
26
|
+
s.add_dependency 'ffi'
|
27
|
+
s.add_dependency 'multi_json'
|
28
|
+
s.add_dependency 'thor'
|
29
|
+
|
30
|
+
s.add_development_dependency 'eventmachine'
|
31
|
+
s.add_development_dependency 'ffi-rzmq'
|
32
|
+
s.add_development_dependency 'perftools.rb'
|
27
33
|
s.add_development_dependency 'pry'
|
28
34
|
s.add_development_dependency 'pry-nav'
|
35
|
+
s.add_development_dependency 'rake'
|
36
|
+
s.add_development_dependency 'rake-compiler'
|
29
37
|
s.add_development_dependency 'rspec'
|
30
|
-
s.add_development_dependency 'yard'
|
31
38
|
s.add_development_dependency 'simplecov'
|
39
|
+
s.add_development_dependency 'yard'
|
32
40
|
end
|
data/spec/benchmark/tasks.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'benchmark'
|
2
|
-
require '
|
2
|
+
require 'support/all'
|
3
3
|
require 'proto/test_service_impl'
|
4
|
+
require 'perftools'
|
4
5
|
|
5
6
|
# Including a way to turn on debug logger for spec runs
|
6
|
-
if ENV["DEBUG"]
|
7
|
+
if ENV["DEBUG"]
|
7
8
|
puts 'debugging'
|
8
9
|
debug_log = File.expand_path('../debug_bench.log', File.dirname(__FILE__) )
|
9
10
|
Protobuf::Logger.configure(:file => debug_log, :level => ::Logger::DEBUG)
|
@@ -59,34 +60,34 @@ namespace :benchmark do
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def sock_client_sock_server(number_tests, test_length, global_bench = nil)
|
63
|
+
load "protobuf/socket.rb"
|
64
|
+
::Protobuf::Rpc::Connector.connector_for_client(true)
|
62
65
|
EM.stop if EM.reactor_running?
|
63
66
|
|
64
67
|
StubServer.new(:server => Protobuf::Rpc::Socket::Server, :port => 9399) do |server|
|
65
|
-
|
66
|
-
client = Spec::Proto::TestService.client(:async => false, :port => 9399)
|
68
|
+
client = Spec::Proto::TestService.client(:async => false, :port => 9399)
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
70
|
+
benchmark_wrapper(global_bench) do |bench|
|
71
|
+
bench.report("SS / SC") do
|
72
|
+
(1..number_tests.to_i).each { client.find(:name => "Test Name" * test_length.to_i, :active => true) }
|
72
73
|
end
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|
76
77
|
|
77
78
|
def sock_client_em_server(number_tests, test_length, global_bench = nil)
|
79
|
+
load "protobuf/socket.rb"
|
80
|
+
::Protobuf::Rpc::Connector.connector_for_client(true)
|
78
81
|
EM.stop if EM.reactor_running?
|
79
82
|
em_thread = Thread.new { EM.run }
|
80
83
|
Thread.pass until EM.reactor_running?
|
81
84
|
|
82
85
|
StubServer.new(:port => 9399) do |server|
|
83
|
-
|
84
|
-
client = Spec::Proto::TestService.client(:async => false, :port => 9399)
|
86
|
+
client = Spec::Proto::TestService.client(:async => false, :port => 9399)
|
85
87
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
88
|
+
benchmark_wrapper(global_bench) do |bench|
|
89
|
+
bench.report("ES / SC") do
|
90
|
+
(1..number_tests.to_i).each { client.find(:name => "Test Name" * test_length.to_i, :active => true) }
|
90
91
|
end
|
91
92
|
end
|
92
93
|
end
|
@@ -96,17 +97,14 @@ namespace :benchmark do
|
|
96
97
|
end
|
97
98
|
|
98
99
|
def zmq_client_zmq_server(number_tests, test_length, global_bench = nil)
|
99
|
-
|
100
|
-
|
101
|
-
require 'protobuf/rpc/servers/zmq/server'
|
100
|
+
load "protobuf/zmq.rb"
|
101
|
+
::Protobuf::Rpc::Connector.connector_for_client(true)
|
102
102
|
StubServer.new(:port => 9399, :server => Protobuf::Rpc::Zmq::Server) do |server|
|
103
|
-
|
104
|
-
client = Spec::Proto::TestService.client(:async => false, :port => 9399)
|
103
|
+
client = Spec::Proto::TestService.client(:async => false, :port => 9399)
|
105
104
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
105
|
+
benchmark_wrapper(global_bench) do |bench|
|
106
|
+
bench.report("ZS / ZC") do
|
107
|
+
(1..number_tests.to_i).each { client.find(:name => "Test Name" * test_length.to_i, :active => true) }
|
110
108
|
end
|
111
109
|
end
|
112
110
|
server.stop
|
@@ -119,6 +117,27 @@ namespace :benchmark do
|
|
119
117
|
zmq_client_zmq_server(args[:number], args[:length])
|
120
118
|
end
|
121
119
|
|
120
|
+
desc "benchmark ZMQ client with ZMQ server and profile"
|
121
|
+
task :zmq_profile, [:number, :length, :profile_output] do |t, args|
|
122
|
+
args.with_defaults(:number => 1000, :length => 100, :profile_output => "/tmp/zmq_profiler_#{Time.now.to_i}")
|
123
|
+
::PerfTools::CpuProfiler.start(args[:profile_output]) do
|
124
|
+
zmq_client_zmq_server(args[:number], args[:length])
|
125
|
+
end
|
126
|
+
|
127
|
+
puts args[:profile_output]
|
128
|
+
end
|
129
|
+
|
130
|
+
desc "benchmark Protobuf Message #new"
|
131
|
+
task :profile_protobuf_new, [:number, :profile_output] do |t, args|
|
132
|
+
args.with_defaults(:number => 1000, :profile_output => "/tmp/profiler_new_#{Time.now.to_i}")
|
133
|
+
create_params = { :name => "The name that we set", :date_created => Time.now.to_i, :status => 2 }
|
134
|
+
::PerfTools::CpuProfiler.start(args[:profile_output]) do
|
135
|
+
args[:number].to_i.times { Spec::Proto::Resource.new(create_params) }
|
136
|
+
end
|
137
|
+
|
138
|
+
puts args[:profile_output]
|
139
|
+
end
|
140
|
+
|
122
141
|
desc "benchmark EventMachine client with EventMachine server"
|
123
142
|
task :em_client_em_server, [:number, :length] do |t, args|
|
124
143
|
args.with_defaults(:number => 1000, :length => 100)
|
@@ -3,6 +3,8 @@ require 'spec/proto/test_service_impl'
|
|
3
3
|
|
4
4
|
describe 'Functional EventMachine Client' do
|
5
5
|
before(:each) do
|
6
|
+
load 'protobuf/evented.rb'
|
7
|
+
::Protobuf::Rpc::Connector.connector_for_client(true)
|
6
8
|
::Spec::Proto::TestService.configure(::Spec::Proto::TestService::DEFAULT_LOCATION)
|
7
9
|
end
|
8
10
|
|
@@ -3,6 +3,8 @@ require 'spec/proto/test_service_impl'
|
|
3
3
|
|
4
4
|
describe 'Functional Socket Client' do
|
5
5
|
before(:all) do
|
6
|
+
load "protobuf/socket.rb"
|
7
|
+
::Protobuf::Rpc::Connector.connector_for_client(true)
|
6
8
|
Thread.abort_on_exception = true
|
7
9
|
server = OpenStruct.new(:server => "127.0.0.1", :port => 9399, :backlog => 100, :threshold => 100)
|
8
10
|
@server_thread = Thread.new(server) { |s| Protobuf::Rpc::SocketRunner.run(s) }
|
@@ -16,18 +18,16 @@ describe 'Functional Socket Client' do
|
|
16
18
|
|
17
19
|
it 'runs fine when required fields are set' do
|
18
20
|
expect {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
raise err.inspect
|
30
|
-
end
|
21
|
+
client = ::Spec::Proto::TestService.client(:async => false)
|
22
|
+
|
23
|
+
client.find(:name => 'Test Name', :active => true) do |c|
|
24
|
+
c.on_success do |succ|
|
25
|
+
succ.name.should eq("Test Name")
|
26
|
+
succ.status.should eq(::Spec::Proto::StatusType::ENABLED)
|
27
|
+
end
|
28
|
+
|
29
|
+
c.on_failure do |err|
|
30
|
+
raise err.inspect
|
31
31
|
end
|
32
32
|
end
|
33
33
|
}.to_not raise_error
|
@@ -35,28 +35,24 @@ describe 'Functional Socket Client' do
|
|
35
35
|
|
36
36
|
it 'calls the on_failure callback when a message is malformed' do
|
37
37
|
error = nil
|
38
|
-
|
39
|
-
|
40
|
-
client = ::Spec::Proto::TestService.client(:async => false)
|
38
|
+
request = ::Spec::Proto::ResourceFindRequest.new(:active => true)
|
39
|
+
client = ::Spec::Proto::TestService.client(:async => false)
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
41
|
+
client.find(request) do |c|
|
42
|
+
c.on_success { raise "shouldn't pass"}
|
43
|
+
c.on_failure {|e| error = e}
|
46
44
|
end
|
47
45
|
error.message.should =~ /ResourceFindRequest.*fields.*improperly set.*"name"/
|
48
46
|
end
|
49
47
|
|
50
48
|
it 'calls the on_failure callback when the request type is wrong' do
|
51
49
|
error = nil
|
52
|
-
|
53
|
-
|
54
|
-
client = ::Spec::Proto::TestService.client(:async => false)
|
50
|
+
request = ::Spec::Proto::Resource.new(:name => 'Test Name')
|
51
|
+
client = ::Spec::Proto::TestService.client(:async => false)
|
55
52
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
53
|
+
client.find(request) do |c|
|
54
|
+
c.on_success { raise "shouldn't pass"}
|
55
|
+
c.on_failure {|e| error = e}
|
60
56
|
end
|
61
57
|
error.message.should =~ /expected request.*ResourceFindRequest.*Resource instead/i
|
62
58
|
end
|
@@ -3,6 +3,8 @@ require 'spec/proto/test_service_impl'
|
|
3
3
|
|
4
4
|
describe 'Functional ZMQ Client' do
|
5
5
|
before(:all) do
|
6
|
+
load "protobuf/zmq.rb"
|
7
|
+
::Protobuf::Rpc::Connector.connector_for_client(true)
|
6
8
|
Thread.abort_on_exception = true
|
7
9
|
server = OpenStruct.new(:server => "127.0.0.1", :port => 9399, :backlog => 100, :threshold => 100)
|
8
10
|
@server_thread = Thread.new(server) { |s| Protobuf::Rpc::ZmqRunner.run(s) }
|
@@ -16,18 +18,16 @@ describe 'Functional ZMQ Client' do
|
|
16
18
|
|
17
19
|
it 'runs fine when required fields are set' do
|
18
20
|
expect {
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
raise err.inspect
|
30
|
-
end
|
21
|
+
client = ::Spec::Proto::TestService.client(:async => false)
|
22
|
+
|
23
|
+
client.find(:name => 'Test Name', :active => true) do |c|
|
24
|
+
c.on_success do |succ|
|
25
|
+
succ.name.should eq("Test Name")
|
26
|
+
succ.status.should eq(::Spec::Proto::StatusType::ENABLED)
|
27
|
+
end
|
28
|
+
|
29
|
+
c.on_failure do |err|
|
30
|
+
raise err.inspect
|
31
31
|
end
|
32
32
|
end
|
33
33
|
}.to_not raise_error
|
@@ -35,28 +35,24 @@ describe 'Functional ZMQ Client' do
|
|
35
35
|
|
36
36
|
it 'calls the on_failure callback when a message is malformed' do
|
37
37
|
error = nil
|
38
|
-
|
39
|
-
|
40
|
-
client = ::Spec::Proto::TestService.client(:async => false)
|
38
|
+
request = ::Spec::Proto::ResourceFindRequest.new(:active => true)
|
39
|
+
client = ::Spec::Proto::TestService.client(:async => false)
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
41
|
+
client.find(request) do |c|
|
42
|
+
c.on_success { raise "shouldn't pass"}
|
43
|
+
c.on_failure {|e| error = e}
|
46
44
|
end
|
47
45
|
error.message.should =~ /ResourceFindRequest.*fields.*improperly set.*"name"/
|
48
46
|
end
|
49
47
|
|
50
48
|
it 'calls the on_failure callback when the request type is wrong' do
|
51
49
|
error = nil
|
52
|
-
|
53
|
-
|
54
|
-
client = ::Spec::Proto::TestService.client(:async => false)
|
50
|
+
request = ::Spec::Proto::Resource.new(:name => 'Test Name')
|
51
|
+
client = ::Spec::Proto::TestService.client(:async => false)
|
55
52
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
53
|
+
client.find(request) do |c|
|
54
|
+
c.on_success { raise "shouldn't pass"}
|
55
|
+
c.on_failure {|e| error = e}
|
60
56
|
end
|
61
57
|
error.message.should =~ /expected request.*ResourceFindRequest.*Resource instead/i
|
62
58
|
end
|