protobuf 2.5.0-java → 2.5.2-java
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/lib/protobuf.rb +13 -0
- data/lib/protobuf/cli.rb +43 -9
- data/lib/protobuf/rpc/connectors/base.rb +6 -5
- data/lib/protobuf/rpc/connectors/common.rb +15 -11
- data/lib/protobuf/rpc/connectors/em_client.rb +1 -1
- data/lib/protobuf/rpc/rpc.pb.rb +27 -92
- data/lib/protobuf/rpc/server.rb +2 -4
- data/lib/protobuf/rpc/servers/evented/server.rb +0 -4
- data/lib/protobuf/rpc/servers/socket/server.rb +1 -1
- data/lib/protobuf/rpc/servers/socket/worker.rb +0 -4
- data/lib/protobuf/rpc/servers/zmq/worker.rb +1 -1
- data/lib/protobuf/rpc/service.rb +32 -11
- data/lib/protobuf/rpc/service_dispatcher.rb +1 -1
- data/lib/protobuf/rpc/stat.rb +4 -4
- data/lib/protobuf/version.rb +1 -1
- data/proto/rpc.proto +27 -38
- data/spec/lib/protobuf/cli_spec.rb +196 -165
- data/spec/lib/protobuf/rpc/connectors/common_spec.rb +48 -12
- data/spec/lib/protobuf_spec.rb +16 -0
- metadata +2 -3
- data/proto/rpc.pb.rb +0 -48
data/README.md
CHANGED
@@ -14,6 +14,8 @@ So let's dive in and see how to work with all three.
|
|
14
14
|
|
15
15
|
## 1. Generating ruby classes from `.proto` files
|
16
16
|
|
17
|
+
_The `protobuf` package is required for compilation. Mac: `brew install protobuf`, Ubuntu: `sudo apt-get install -y protobuf`_
|
18
|
+
|
17
19
|
Protocol Buffers are great because they allow you to clearly define data storage or data transfer packets. Google officially supports Java, C++, and Python for compilation and usage. Let's make it ruby aware!
|
18
20
|
|
19
21
|
Let's say you have a `defs.proto` file that defines a User message.
|
@@ -24,9 +26,11 @@ message User {
|
|
24
26
|
required string first_name = 1;
|
25
27
|
required string last_name = 2;
|
26
28
|
}
|
29
|
+
```
|
27
30
|
|
28
31
|
Now let's compile that definition to ruby:
|
29
32
|
|
33
|
+
```
|
30
34
|
$ rprotoc defs.proto --ruby_out ./lib
|
31
35
|
```
|
32
36
|
|
data/lib/protobuf.rb
CHANGED
@@ -14,6 +14,19 @@ module Protobuf
|
|
14
14
|
|
15
15
|
module_function
|
16
16
|
|
17
|
+
# Client Host
|
18
|
+
#
|
19
|
+
# Default: `hostname` of the system
|
20
|
+
#
|
21
|
+
# The name or address of the host to use during client RPC calls.
|
22
|
+
def self.client_host
|
23
|
+
@_client_host ||= `hostname`.chomp
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.client_host=(host)
|
27
|
+
@_client_host = host
|
28
|
+
end
|
29
|
+
|
17
30
|
# Connector Type
|
18
31
|
#
|
19
32
|
# Default: socket
|
data/lib/protobuf/cli.rb
CHANGED
@@ -31,7 +31,7 @@ module Protobuf
|
|
31
31
|
|
32
32
|
option :debug, :type => :boolean, :default => false, :aliases => %w(-d), :desc => 'Debug Mode. Override log level to DEBUG.'
|
33
33
|
option :gc_pause_request, :type => :boolean, :default => false, :desc => 'Enable/Disable GC pause during request.'
|
34
|
-
option :print_deprecation_warnings, :type => :boolean, :default =>
|
34
|
+
option :print_deprecation_warnings, :type => :boolean, :default => nil, :desc => 'Cause use of deprecated fields to be printed or ignored.'
|
35
35
|
|
36
36
|
def start(app_file)
|
37
37
|
debug_say 'Configuring the rpc_server process'
|
@@ -61,13 +61,23 @@ module Protobuf
|
|
61
61
|
|
62
62
|
# Tell protobuf how to handle the printing of deprecated field usage.
|
63
63
|
def configure_deprecation_warnings
|
64
|
-
|
64
|
+
if options.print_deprecation_warnings.nil?
|
65
|
+
::Protobuf.print_deprecation_warnings = !ENV.key?("PB_IGNORE_DEPRECATIONS")
|
66
|
+
else
|
67
|
+
::Protobuf.print_deprecation_warnings = options.print_deprecation_warnings?
|
68
|
+
end
|
65
69
|
end
|
66
70
|
|
67
71
|
# If we pause during request we don't need to pause in serialization
|
68
72
|
def configure_gc
|
69
73
|
debug_say 'Configuring gc'
|
70
|
-
|
74
|
+
|
75
|
+
if defined?(JRUBY_VERSION)
|
76
|
+
# GC.enable/disable are noop's on Jruby
|
77
|
+
::Protobuf.gc_pause_server_request = false
|
78
|
+
else
|
79
|
+
::Protobuf.gc_pause_server_request = options.gc_pause_request?
|
80
|
+
end
|
71
81
|
end
|
72
82
|
|
73
83
|
# Setup the protobuf logger.
|
@@ -91,15 +101,24 @@ module Protobuf
|
|
91
101
|
def configure_server_mode
|
92
102
|
debug_say 'Configuring runner mode'
|
93
103
|
if options.zmq? && ! options.evented? && ! options.socket?
|
94
|
-
|
95
|
-
@runner = ::Protobuf::Rpc::ZmqRunner
|
104
|
+
server_zmq!
|
96
105
|
elsif options.evented? && ! options.zmq? && ! options.socket?
|
97
|
-
|
98
|
-
|
106
|
+
server_evented!
|
107
|
+
elsif (env_server_type = ENV["PB_SERVER_TYPE"])
|
108
|
+
case
|
109
|
+
when env_server_type =~ /zmq/i then
|
110
|
+
server_zmq!
|
111
|
+
when env_server_type =~ /socket/i then
|
112
|
+
server_socket!
|
113
|
+
when env_server_type =~ /evented/i then
|
114
|
+
server_evented!
|
115
|
+
else
|
116
|
+
say "WARNING: You have provided incorrect option 'PB_SERVER_TYPE=#{env_server_type}'. Defaulting to socket mode.", :yellow
|
117
|
+
server_socket!
|
118
|
+
end
|
99
119
|
else
|
100
120
|
say 'WARNING: You have provided multiple mode options. Defaulting to socket mode.', :yellow if multi_mode?
|
101
|
-
|
102
|
-
@runner = ::Protobuf::Rpc::SocketRunner
|
121
|
+
server_socket!
|
103
122
|
end
|
104
123
|
end
|
105
124
|
|
@@ -173,6 +192,21 @@ module Protobuf
|
|
173
192
|
exit(1)
|
174
193
|
end
|
175
194
|
|
195
|
+
def server_evented!
|
196
|
+
@mode = :evented
|
197
|
+
@runner = ::Protobuf::Rpc::EventedRunner
|
198
|
+
end
|
199
|
+
|
200
|
+
def server_socket!
|
201
|
+
@mode = :socket
|
202
|
+
@runner = ::Protobuf::Rpc::SocketRunner
|
203
|
+
end
|
204
|
+
|
205
|
+
def server_zmq!
|
206
|
+
@mode = :zmq
|
207
|
+
@runner = ::Protobuf::Rpc::ZmqRunner
|
208
|
+
end
|
209
|
+
|
176
210
|
# Start the runner and log the relevant options.
|
177
211
|
def start_server!
|
178
212
|
debug_say 'Invoking server start'
|
@@ -9,14 +9,15 @@ module Protobuf
|
|
9
9
|
module Rpc
|
10
10
|
module Connectors
|
11
11
|
DEFAULT_OPTIONS = {
|
12
|
-
:service => nil, # Service
|
13
|
-
:method => nil, # Service method to
|
14
|
-
:host => '127.0.0.1', #
|
15
|
-
:port => '9399', #
|
12
|
+
:service => nil, # Fully-qualified Service class
|
13
|
+
:method => nil, # Service method to invoke
|
14
|
+
:host => '127.0.0.1', # The hostname or address of the service (usually overridden or pre-configured)
|
15
|
+
:port => '9399', # The port of the service (usually overridden or pre-configured)
|
16
16
|
:request => nil, # The request object sent by the client
|
17
17
|
:request_type => nil, # The request type expected by the client
|
18
18
|
:response_type => nil, # The response type expected by the client
|
19
|
-
:timeout => 30
|
19
|
+
:timeout => 30, # The default timeout for the request, also handled by client.rb
|
20
|
+
:client_host => nil # The hostname or address of this client
|
20
21
|
}
|
21
22
|
|
22
23
|
class Base
|
@@ -11,6 +11,10 @@ module Protobuf
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def request_caller
|
15
|
+
@options[:client_host] || ::Protobuf.client_host
|
16
|
+
end
|
17
|
+
|
14
18
|
def complete
|
15
19
|
@stats.stop
|
16
20
|
log_info { @stats.to_s }
|
@@ -101,21 +105,21 @@ module Protobuf
|
|
101
105
|
fail(:RPC_ERROR, "Connection error: #{e.message}")
|
102
106
|
end
|
103
107
|
|
104
|
-
def
|
105
|
-
validate_request_type
|
108
|
+
def request_bytes
|
109
|
+
validate_request_type!
|
110
|
+
fields = { :service_name => @options[:service].name,
|
111
|
+
:method_name => @options[:method].to_s,
|
112
|
+
:request_proto => @options[:request],
|
113
|
+
:caller => request_caller }
|
106
114
|
|
107
|
-
return ::Protobuf::Socketrpc::Request.new(
|
108
|
-
:service_name => @options[:service].name,
|
109
|
-
:method_name => @options[:method].to_s,
|
110
|
-
:request_proto => @options[:request]
|
111
|
-
).serialize_to_string
|
115
|
+
return ::Protobuf::Socketrpc::Request.new(fields).serialize_to_string
|
112
116
|
rescue => e
|
113
117
|
fail(:INVALID_REQUEST_PROTO, "Could not set request proto: #{e.message}")
|
114
118
|
end
|
115
119
|
|
116
120
|
def setup_connection
|
117
121
|
initialize_stats
|
118
|
-
@request_data =
|
122
|
+
@request_data = request_bytes
|
119
123
|
end
|
120
124
|
|
121
125
|
def succeed(response)
|
@@ -129,7 +133,7 @@ module Protobuf
|
|
129
133
|
complete
|
130
134
|
end
|
131
135
|
|
132
|
-
def validate_request_type
|
136
|
+
def validate_request_type!
|
133
137
|
unless @options[:request].class == @options[:request_type]
|
134
138
|
expected = @options[:request_type].name
|
135
139
|
actual = @options[:request].class.name
|
@@ -138,13 +142,13 @@ module Protobuf
|
|
138
142
|
end
|
139
143
|
|
140
144
|
def verify_callbacks
|
141
|
-
|
145
|
+
unless any_callbacks?
|
142
146
|
log_debug { sign_message("No callbacks set, using data_callback") }
|
143
147
|
@success_cb = @failure_cb = self.method(:data_callback)
|
144
148
|
end
|
145
149
|
end
|
146
150
|
|
147
|
-
def verify_options
|
151
|
+
def verify_options!
|
148
152
|
# Verify the options that are necessary and merge them in
|
149
153
|
[:service, :method, :host, :port].each do |opt|
|
150
154
|
fail(:RPC_ERROR, "Invalid client connection configuration. #{opt} must be a defined option.") if @options[opt].nil?
|
@@ -17,7 +17,7 @@ module Protobuf
|
|
17
17
|
@failure_cb = failure_cb
|
18
18
|
@options = DEFAULT_OPTIONS.merge(options)
|
19
19
|
@response_buffer = ::Protobuf::Rpc::Buffer.new(:read)
|
20
|
-
verify_options
|
20
|
+
verify_options!
|
21
21
|
|
22
22
|
log_debug { sign_message("Client Initialized: #{options.inspect}") }
|
23
23
|
rescue => e
|
data/lib/protobuf/rpc/rpc.pb.rb
CHANGED
@@ -1,78 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
# //
|
5
|
-
# // Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# // of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# // in the Software without restriction, including without limitation the rights
|
8
|
-
# // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# // copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# // furnished to do so, subject to the following conditions:
|
11
|
-
# //
|
12
|
-
# // The above copyright notice and this permission notice shall be included in
|
13
|
-
# // all copies or substantial portions of the Software.
|
14
|
-
# //
|
15
|
-
# // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# // THE SOFTWARE.
|
22
|
-
#
|
23
|
-
# // Author: Shardul Deo
|
24
|
-
# //
|
25
|
-
# // Protobufs needed for socket rpcs.
|
26
|
-
#
|
27
|
-
# package protobuf.socketrpc;
|
28
|
-
#
|
29
|
-
# message Request {
|
30
|
-
#
|
31
|
-
# // RPC service full name
|
32
|
-
# required string service_name = 1;
|
33
|
-
#
|
34
|
-
# // RPC method name
|
35
|
-
# required string method_name = 2;
|
36
|
-
#
|
37
|
-
# // RPC request proto
|
38
|
-
# required bytes request_proto = 3;
|
39
|
-
# }
|
40
|
-
#
|
41
|
-
# message Response {
|
42
|
-
#
|
43
|
-
# // RPC response proto
|
44
|
-
# optional bytes response_proto = 1;
|
45
|
-
#
|
46
|
-
# // Error, if any
|
47
|
-
# optional string error = 2;
|
48
|
-
#
|
49
|
-
# // Was callback invoked
|
50
|
-
# optional bool callback = 3 [default = false];
|
51
|
-
#
|
52
|
-
# // Error Reason
|
53
|
-
# optional ErrorReason error_reason = 4;
|
54
|
-
# }
|
55
|
-
#
|
56
|
-
# // Possible error reasons
|
57
|
-
# // The server-side errors are returned in the response from the server.
|
58
|
-
# // The client-side errors are returned by the client-side code when it doesn't
|
59
|
-
# // have a response from the server.
|
60
|
-
# enum ErrorReason {
|
61
|
-
#
|
62
|
-
# // Server-side errors
|
63
|
-
# BAD_REQUEST_DATA = 0; // Server received bad request data
|
64
|
-
# BAD_REQUEST_PROTO = 1; // Server received bad request proto
|
65
|
-
# SERVICE_NOT_FOUND = 2; // Service not found on server
|
66
|
-
# METHOD_NOT_FOUND = 3; // Method not found on server
|
67
|
-
# RPC_ERROR = 4; // Rpc threw exception on server
|
68
|
-
# RPC_FAILED = 5; // Rpc failed on server
|
69
|
-
#
|
70
|
-
# // Client-side errors (these are returned by the client-side code)
|
71
|
-
# INVALID_REQUEST_PROTO = 6; // Rpc was called with invalid request proto
|
72
|
-
# BAD_RESPONSE_PROTO = 7; // Server returned a bad response proto
|
73
|
-
# UNKNOWN_HOST = 8; // Could not find supplied host
|
74
|
-
# IO_ERROR = 9; // I/O error while communicating with server
|
75
|
-
# }
|
1
|
+
##
|
2
|
+
# This file is auto-generated. DO NOT EDIT!
|
3
|
+
#
|
76
4
|
require 'protobuf/message'
|
77
5
|
|
78
6
|
module Protobuf
|
@@ -91,28 +19,35 @@ module Protobuf
|
|
91
19
|
##
|
92
20
|
# Enum Values
|
93
21
|
#
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
22
|
+
class ErrorReason
|
23
|
+
define :BAD_REQUEST_DATA, 0
|
24
|
+
define :BAD_REQUEST_PROTO, 1
|
25
|
+
define :SERVICE_NOT_FOUND, 2
|
26
|
+
define :METHOD_NOT_FOUND, 3
|
27
|
+
define :RPC_ERROR, 4
|
28
|
+
define :RPC_FAILED, 5
|
29
|
+
define :INVALID_REQUEST_PROTO, 6
|
30
|
+
define :BAD_RESPONSE_PROTO, 7
|
31
|
+
define :UNKNOWN_HOST, 8
|
32
|
+
define :IO_ERROR, 9
|
33
|
+
end
|
104
34
|
|
105
35
|
##
|
106
36
|
# Message Fields
|
107
37
|
#
|
108
|
-
|
109
|
-
|
110
|
-
|
38
|
+
class Request
|
39
|
+
required ::Protobuf::Field::StringField, :service_name, 1
|
40
|
+
required ::Protobuf::Field::StringField, :method_name, 2
|
41
|
+
optional ::Protobuf::Field::BytesField, :request_proto, 3
|
42
|
+
optional ::Protobuf::Field::StringField, :caller, 4
|
43
|
+
end
|
111
44
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
45
|
+
class Response
|
46
|
+
optional ::Protobuf::Field::BytesField, :response_proto, 1
|
47
|
+
optional ::Protobuf::Field::StringField, :error, 2
|
48
|
+
optional ::Protobuf::Field::BoolField, :callback, 3, :default => false
|
49
|
+
optional ::Protobuf::Socketrpc::ErrorReason, :error_reason, 4
|
50
|
+
end
|
116
51
|
|
117
52
|
end
|
118
53
|
end
|
data/lib/protobuf/rpc/server.rb
CHANGED
@@ -14,7 +14,6 @@ module Protobuf
|
|
14
14
|
@request = ::Protobuf::Socketrpc::Request.new
|
15
15
|
@response = ::Protobuf::Socketrpc::Response.new
|
16
16
|
@stats = Protobuf::Rpc::Stat.new(:SERVER)
|
17
|
-
set_peer
|
18
17
|
end
|
19
18
|
|
20
19
|
def disable_gc!
|
@@ -25,12 +24,11 @@ module Protobuf
|
|
25
24
|
::GC.enable && ::GC.start if ::Protobuf.gc_pause_server_request?
|
26
25
|
end
|
27
26
|
|
28
|
-
# no-op, implemented by including class if desired.
|
29
|
-
def set_peer; end
|
30
|
-
|
31
27
|
# Invoke the service method dictated by the proto wrapper request object
|
32
28
|
def handle_client
|
33
29
|
parse_request_from_buffer
|
30
|
+
@stats.client = @request.caller
|
31
|
+
|
34
32
|
@dispatcher = ::Protobuf::Rpc::ServiceDispatcher.new(@request)
|
35
33
|
@stats.dispatcher = @dispatcher
|
36
34
|
|
@@ -74,7 +74,7 @@ module Protobuf
|
|
74
74
|
client, sockaddr = @server.accept
|
75
75
|
@listen_fds << client
|
76
76
|
else
|
77
|
-
|
77
|
+
unless @working.include?(client)
|
78
78
|
@working << @listen_fds.delete(client)
|
79
79
|
log_debug { sign_message("Working") }
|
80
80
|
@threads << { :thread => new_worker(client), :socket => client }
|
@@ -29,7 +29,7 @@ module Protobuf
|
|
29
29
|
def handle_request(socket)
|
30
30
|
@request_data = ''
|
31
31
|
zmq_error_check(socket.recv_string(@request_data))
|
32
|
-
log_debug { sign_message("handling request") }
|
32
|
+
log_debug { sign_message("handling request") } unless @request_data.nil?
|
33
33
|
end
|
34
34
|
|
35
35
|
def run
|
data/lib/protobuf/rpc/service.rb
CHANGED
@@ -15,8 +15,6 @@ module Protobuf
|
|
15
15
|
include ::Protobuf::Logger::LogMethods
|
16
16
|
|
17
17
|
|
18
|
-
attr_reader :response, :rpc
|
19
|
-
|
20
18
|
DEFAULT_HOST = '127.0.0.1'.freeze
|
21
19
|
DEFAULT_PORT = 9399
|
22
20
|
|
@@ -102,23 +100,26 @@ module Protobuf
|
|
102
100
|
# Instance Methods
|
103
101
|
#
|
104
102
|
|
103
|
+
attr_reader :response, :method_name, :client_host
|
104
|
+
|
105
105
|
# Initialize a service with the rpc endpoint name and the bytes
|
106
106
|
# for the request.
|
107
|
-
def initialize(
|
108
|
-
@
|
109
|
-
@
|
107
|
+
def initialize(method_name, request_bytes, client_host = nil)
|
108
|
+
@method_name = method_name
|
109
|
+
@client_host = client_host
|
110
|
+
@_request_bytes = request_bytes
|
110
111
|
end
|
111
112
|
|
112
113
|
# Register a failure callback for use when rpc_failed is invoked.
|
113
114
|
#
|
114
115
|
def on_rpc_failed(callable)
|
115
|
-
@
|
116
|
+
@_rpc_failed_callback ||= callable
|
116
117
|
end
|
117
118
|
|
118
119
|
# Response object for this rpc cycle. Not assignable.
|
119
120
|
#
|
120
121
|
def response
|
121
|
-
@_response ||=
|
122
|
+
@_response ||= response_type.new
|
122
123
|
end
|
123
124
|
|
124
125
|
# Convenience method to get back to class method.
|
@@ -144,18 +145,26 @@ module Protobuf
|
|
144
145
|
|
145
146
|
private
|
146
147
|
|
148
|
+
def response_type
|
149
|
+
@_response_type ||= rpcs[@method_name].response_type
|
150
|
+
end
|
151
|
+
|
147
152
|
# Request object for this rpc cycle. Not assignable.
|
148
153
|
#
|
149
154
|
def request
|
150
|
-
@_request ||= if @
|
151
|
-
|
155
|
+
@_request ||= if @_request_bytes.present?
|
156
|
+
request_type.new.parse_from_string(@_request_bytes)
|
152
157
|
else
|
153
|
-
|
158
|
+
request_type.new
|
154
159
|
end
|
155
160
|
rescue => e
|
156
161
|
raise BadRequestProto, "Unable to parse request: #{e.message}"
|
157
162
|
end
|
158
163
|
|
164
|
+
def request_type
|
165
|
+
@_request_type ||= rpcs[@method_name].request_type
|
166
|
+
end
|
167
|
+
|
159
168
|
# Sugar to make an rpc method feel like a controller method.
|
160
169
|
# If this method is not called, the response will be the memoized
|
161
170
|
# object returned by the response reader.
|
@@ -165,10 +174,22 @@ module Protobuf
|
|
165
174
|
end
|
166
175
|
alias_method :return_from_whence_you_came, :respond_with
|
167
176
|
|
177
|
+
# Renamed attribute from prior implementaiton due to lack of clarity
|
178
|
+
# in what the variable contained. DEPRECATED.
|
179
|
+
def rpc
|
180
|
+
if ::Protobuf.print_deprecation_warnings?
|
181
|
+
$stderr.puts <<-ERROR
|
182
|
+
[WARNING] Service#rpc method has been deprecated
|
183
|
+
and will be removed in a future version of protobuf.
|
184
|
+
ERROR
|
185
|
+
end
|
186
|
+
@method_name
|
187
|
+
end
|
188
|
+
|
168
189
|
# Automatically fail a service method.
|
169
190
|
#
|
170
191
|
def rpc_failed(message)
|
171
|
-
@
|
192
|
+
@_rpc_failed_callback.call(message)
|
172
193
|
end
|
173
194
|
|
174
195
|
end
|
@@ -74,7 +74,7 @@ module Protobuf
|
|
74
74
|
request_proto = outer_request.has_field?(:request_proto) ? outer_request.request_proto : nil
|
75
75
|
|
76
76
|
if service_klass.rpc_method?(method_name)
|
77
|
-
self.service = service_klass.new(method_name, request_proto)
|
77
|
+
self.service = service_klass.new(method_name, request_proto, outer_request.caller)
|
78
78
|
self.callable_method = service.callable_rpc_method(method_name)
|
79
79
|
self.definition = service.rpcs[method_name]
|
80
80
|
else
|
data/lib/protobuf/rpc/stat.rb
CHANGED
@@ -14,12 +14,12 @@ module Protobuf
|
|
14
14
|
start
|
15
15
|
end
|
16
16
|
|
17
|
-
def client=(
|
18
|
-
@client =
|
17
|
+
def client=(client_host)
|
18
|
+
@client = client_host
|
19
19
|
end
|
20
20
|
|
21
21
|
def client
|
22
|
-
@client
|
22
|
+
@client || nil
|
23
23
|
end
|
24
24
|
|
25
25
|
def method_name
|
@@ -47,7 +47,7 @@ module Protobuf
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def stop
|
50
|
-
start
|
50
|
+
start unless @start_time
|
51
51
|
@end_time ||= Time.now
|
52
52
|
end
|
53
53
|
|
data/lib/protobuf/version.rb
CHANGED
data/proto/rpc.proto
CHANGED
@@ -18,56 +18,45 @@
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
// THE SOFTWARE.
|
20
20
|
|
21
|
-
//
|
21
|
+
// Authors: Shardul Deo, BJ Neilsen
|
22
22
|
//
|
23
23
|
// Protobufs needed for socket rpcs.
|
24
24
|
|
25
25
|
package protobuf.socketrpc;
|
26
26
|
|
27
|
-
message Request
|
28
|
-
|
29
|
-
//
|
30
|
-
required string
|
31
|
-
|
32
|
-
//
|
33
|
-
required string method_name = 2;
|
34
|
-
|
35
|
-
// RPC request proto
|
36
|
-
optional bytes request_proto = 3;
|
27
|
+
message Request
|
28
|
+
{
|
29
|
+
required string service_name = 1; // Fully- qualified Service class name
|
30
|
+
required string method_name = 2; // Service method to invoke
|
31
|
+
optional bytes request_proto = 3; // Serialized request bytes
|
32
|
+
optional string caller = 4; // Calling hostname or address
|
37
33
|
}
|
38
34
|
|
39
|
-
message Response
|
40
|
-
|
41
|
-
//
|
42
|
-
optional
|
43
|
-
|
44
|
-
// Error
|
45
|
-
optional string error = 2;
|
46
|
-
|
47
|
-
// Was callback invoked
|
48
|
-
optional bool callback = 3 [default = false];
|
49
|
-
|
50
|
-
// Error Reason
|
51
|
-
optional ErrorReason error_reason = 4;
|
35
|
+
message Response
|
36
|
+
{
|
37
|
+
optional bytes response_proto = 1; // Serialized response
|
38
|
+
optional string error = 2; // Error message, if any
|
39
|
+
optional bool callback = 3 [default = false]; // Was callback invoked (not sure what this is for)
|
40
|
+
optional ErrorReason error_reason = 4; // Error Reason
|
52
41
|
}
|
53
42
|
|
54
43
|
// Possible error reasons
|
55
44
|
// The server-side errors are returned in the response from the server.
|
56
|
-
// The client-side errors are returned by the client-side code when it doesn't
|
45
|
+
// The client-side errors are returned by the client-side code when it doesn't
|
57
46
|
// have a response from the server.
|
58
|
-
enum ErrorReason
|
59
|
-
|
47
|
+
enum ErrorReason
|
48
|
+
{
|
60
49
|
// Server-side errors
|
61
|
-
BAD_REQUEST_DATA = 0;
|
62
|
-
BAD_REQUEST_PROTO = 1;
|
63
|
-
SERVICE_NOT_FOUND = 2;
|
64
|
-
METHOD_NOT_FOUND = 3;
|
65
|
-
RPC_ERROR = 4;
|
66
|
-
RPC_FAILED = 5;
|
67
|
-
|
50
|
+
BAD_REQUEST_DATA = 0; // Server received bad request data
|
51
|
+
BAD_REQUEST_PROTO = 1; // Server received bad request proto
|
52
|
+
SERVICE_NOT_FOUND = 2; // Service not found on server
|
53
|
+
METHOD_NOT_FOUND = 3; // Method not found on server
|
54
|
+
RPC_ERROR = 4; // Rpc threw exception on server
|
55
|
+
RPC_FAILED = 5; // Rpc failed on server
|
56
|
+
|
68
57
|
// Client-side errors (these are returned by the client-side code)
|
69
|
-
INVALID_REQUEST_PROTO = 6;
|
70
|
-
BAD_RESPONSE_PROTO = 7;
|
71
|
-
UNKNOWN_HOST = 8;
|
72
|
-
IO_ERROR = 9;
|
58
|
+
INVALID_REQUEST_PROTO = 6; // Rpc was called with invalid request proto
|
59
|
+
BAD_RESPONSE_PROTO = 7; // Server returned a bad response proto
|
60
|
+
UNKNOWN_HOST = 8; // Could not find supplied host
|
61
|
+
IO_ERROR = 9; // I/O error while communicating with server
|
73
62
|
}
|
@@ -3,127 +3,134 @@ require 'protobuf/cli'
|
|
3
3
|
|
4
4
|
describe ::Protobuf::CLI do
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
6
|
+
let(:app_file) do
|
7
|
+
File.expand_path('../../../support/test_app_file.rb', __FILE__)
|
8
|
+
end
|
9
|
+
|
10
|
+
before do
|
11
|
+
::Protobuf::Rpc::SocketRunner.stub(:run)
|
12
|
+
::Protobuf::Rpc::ZmqRunner.stub(:run)
|
13
|
+
::Protobuf::Rpc::EventedRunner.stub(:run)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#start' do
|
17
|
+
let(:base_args) { [ 'start', app_file ] }
|
18
|
+
let(:test_args) { [] }
|
19
|
+
let(:args) { base_args + test_args }
|
20
|
+
|
21
|
+
context 'host option' do
|
22
|
+
let(:test_args) { [ '--host=123.123.123.123' ] }
|
23
|
+
|
24
|
+
it 'sends the host option to the runner' do
|
25
|
+
::Protobuf::Rpc::SocketRunner.should_receive(:run) do |options|
|
26
|
+
options[:host].should eq '123.123.123.123'
|
27
|
+
end
|
28
|
+
described_class.start(args)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'port option' do
|
33
|
+
let(:test_args) { [ '--port=12345' ] }
|
34
|
+
|
35
|
+
it 'sends the port option to the runner' do
|
36
|
+
::Protobuf::Rpc::SocketRunner.should_receive(:run) do |options|
|
37
|
+
options[:port].should eq 12345
|
38
|
+
end
|
39
|
+
described_class.start(args)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'threads option' do
|
44
|
+
let(:test_args) { [ '--threads=500' ] }
|
45
|
+
|
46
|
+
it 'sends the threads option to the runner' do
|
47
|
+
::Protobuf::Rpc::SocketRunner.should_receive(:run) do |options|
|
48
|
+
options[:threads].should eq 500
|
49
|
+
end
|
50
|
+
described_class.start(args)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'backlog option' do
|
55
|
+
let(:test_args) { [ '--backlog=500' ] }
|
56
|
+
|
57
|
+
it 'sends the backlog option to the runner' do
|
58
|
+
::Protobuf::Rpc::SocketRunner.should_receive(:run) do |options|
|
59
|
+
options[:backlog].should eq 500
|
60
|
+
end
|
61
|
+
described_class.start(args)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'threshold option' do
|
66
|
+
let(:test_args) { [ '--threshold=500' ] }
|
67
|
+
|
68
|
+
it 'sends the backlog option to the runner' do
|
69
|
+
::Protobuf::Rpc::SocketRunner.should_receive(:run) do |options|
|
70
|
+
options[:threshold].should eq 500
|
71
|
+
end
|
72
|
+
described_class.start(args)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'log options' do
|
77
|
+
let(:test_args) { [ '--log=mylog.log', '--level=0' ] }
|
78
|
+
|
79
|
+
it 'sends the log file and level options to the runner' do
|
80
|
+
::Protobuf::Logger.should_receive(:configure) do |options|
|
81
|
+
options[:file].should eq 'mylog.log'
|
82
|
+
options[:level].should eq 0
|
83
|
+
end
|
84
|
+
described_class.start(args)
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when debugging' do
|
88
|
+
let(:test_args) { [ '--level=3', '--debug' ] }
|
89
|
+
|
90
|
+
it 'overrides the log-level to DEBUG' do
|
91
|
+
::Protobuf::Logger.should_receive(:configure) do |options|
|
92
|
+
options[:level].should eq ::Logger::DEBUG
|
93
|
+
end
|
94
|
+
described_class.start(args)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'gc options' do
|
100
|
+
|
101
|
+
context 'when gc options are not present' do
|
102
|
+
let(:test_args) { [] }
|
103
|
+
|
104
|
+
it 'sets both request and serialization pausing to false' do
|
105
|
+
described_class.start(args)
|
106
|
+
::Protobuf.gc_pause_server_request?.should be_false
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'request pausing' do
|
111
|
+
let(:test_args) { [ '--gc_pause_request' ] }
|
112
|
+
|
113
|
+
it 'sets the configuration option to GC pause server request' do
|
114
|
+
described_class.start(args)
|
115
|
+
::Protobuf.gc_pause_server_request?.should be_true
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'deprecation options' do
|
121
121
|
context 'when not given' do
|
122
122
|
let(:test_args) { [] }
|
123
123
|
|
124
|
-
it 'sets the deprecation warning flag to
|
124
|
+
it 'sets the deprecation warning flag to true when no ENV is present and no command line option' do
|
125
|
+
described_class.start(args)
|
126
|
+
::Protobuf.print_deprecation_warnings?.should be_true
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'sets the deprecation warning flag to false if ENV["PB_IGNORE_DEPRECATIONS"] is present' do
|
130
|
+
ENV["PB_IGNORE_DEPRECATIONS"] = "1"
|
125
131
|
described_class.start(args)
|
126
|
-
|
132
|
+
::Protobuf.print_deprecation_warnings?.should be_false
|
133
|
+
ENV.delete("PB_IGNORE_DEPRECATIONS")
|
127
134
|
end
|
128
135
|
end
|
129
136
|
|
@@ -132,7 +139,7 @@ describe ::Protobuf::CLI do
|
|
132
139
|
|
133
140
|
it 'sets the deprecation warning flag to true' do
|
134
141
|
described_class.start(args)
|
135
|
-
|
142
|
+
::Protobuf.print_deprecation_warnings?.should be_true
|
136
143
|
end
|
137
144
|
end
|
138
145
|
|
@@ -141,72 +148,96 @@ describe ::Protobuf::CLI do
|
|
141
148
|
|
142
149
|
it 'sets the deprecation warning flag to false' do
|
143
150
|
described_class.start(args)
|
144
|
-
|
151
|
+
::Protobuf.print_deprecation_warnings?.should be_false
|
145
152
|
end
|
146
153
|
end
|
147
|
-
|
154
|
+
end
|
148
155
|
|
149
|
-
|
156
|
+
context 'run modes' do
|
150
157
|
|
151
|
-
|
152
|
-
|
158
|
+
context 'socket' do
|
159
|
+
let(:test_args) { [ '--socket' ] }
|
160
|
+
let(:runner) { ::Protobuf::Rpc::SocketRunner }
|
153
161
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
162
|
+
before do
|
163
|
+
::Protobuf::Rpc::EventedRunner.should_not_receive(:run)
|
164
|
+
::Protobuf::Rpc::ZmqRunner.should_not_receive(:run)
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'is activated by the --socket switch' do
|
168
|
+
runner.should_receive(:run)
|
169
|
+
described_class.start(args)
|
170
|
+
end
|
158
171
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
172
|
+
it 'is activated by PB_SERVER_TYPE=Socket ENV variable' do
|
173
|
+
ENV['PB_SERVER_TYPE'] = "Socket"
|
174
|
+
runner.should_receive(:run)
|
175
|
+
described_class.start(args)
|
176
|
+
ENV.delete('PB_SERVER_TYPE')
|
177
|
+
end
|
163
178
|
|
164
|
-
|
179
|
+
it 'configures the connector type to be socket' do
|
165
180
|
load "protobuf/socket.rb"
|
166
|
-
|
167
|
-
|
168
|
-
|
181
|
+
::Protobuf.connector_type.should == :socket
|
182
|
+
end
|
183
|
+
end
|
169
184
|
|
170
|
-
|
171
|
-
|
185
|
+
context 'evented' do
|
186
|
+
let(:test_args) { [ '--evented' ] }
|
187
|
+
let(:runner) { ::Protobuf::Rpc::EventedRunner }
|
172
188
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
189
|
+
before do
|
190
|
+
::Protobuf::Rpc::SocketRunner.should_not_receive(:run)
|
191
|
+
::Protobuf::Rpc::ZmqRunner.should_not_receive(:run)
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'is activated by the --evented switch' do
|
195
|
+
runner.should_receive(:run)
|
196
|
+
described_class.start(args)
|
197
|
+
end
|
177
198
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
199
|
+
it 'is activated by PB_SERVER_TYPE=Evented ENV variable' do
|
200
|
+
ENV['PB_SERVER_TYPE'] = "Evented"
|
201
|
+
runner.should_receive(:run)
|
202
|
+
described_class.start(args)
|
203
|
+
ENV.delete('PB_SERVER_TYPE')
|
204
|
+
end
|
182
205
|
|
183
|
-
|
206
|
+
it 'configures the connector type to be evented' do
|
184
207
|
load "protobuf/evented.rb"
|
185
|
-
|
186
|
-
|
187
|
-
|
208
|
+
::Protobuf.connector_type.should == :evented
|
209
|
+
end
|
210
|
+
end
|
188
211
|
|
189
|
-
|
190
|
-
|
212
|
+
context 'zmq' do
|
213
|
+
let(:test_args) { [ '--zmq' ] }
|
214
|
+
let(:runner) { ::Protobuf::Rpc::ZmqRunner }
|
191
215
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
216
|
+
before do
|
217
|
+
::Protobuf::Rpc::SocketRunner.should_not_receive(:run)
|
218
|
+
::Protobuf::Rpc::EventedRunner.should_not_receive(:run)
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'is activated by the --zmq switch' do
|
222
|
+
runner.should_receive(:run)
|
223
|
+
described_class.start(args)
|
224
|
+
end
|
196
225
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
226
|
+
it 'is activated by PB_SERVER_TYPE=Zmq ENV variable' do
|
227
|
+
ENV['PB_SERVER_TYPE'] = "Zmq"
|
228
|
+
runner.should_receive(:run)
|
229
|
+
described_class.start(args)
|
230
|
+
ENV.delete('PB_SERVER_TYPE')
|
231
|
+
end
|
201
232
|
|
202
|
-
|
233
|
+
it 'configures the connector type to be zmq' do
|
203
234
|
load "protobuf/zmq.rb"
|
204
|
-
|
205
|
-
|
206
|
-
|
235
|
+
::Protobuf.connector_type.should == :zmq
|
236
|
+
end
|
237
|
+
end
|
207
238
|
|
208
|
-
|
239
|
+
end
|
209
240
|
|
210
|
-
|
241
|
+
end
|
211
242
|
|
212
243
|
end
|
@@ -10,20 +10,23 @@ describe Protobuf::Rpc::Connectors::Common do
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
let(:subject_options) { {} }
|
14
|
+
|
15
|
+
subject { @subject ||= common_class.new(subject_options) }
|
14
16
|
|
15
17
|
context "API" do
|
16
|
-
specify{ subject.respond_to?(:any_callbacks?).should be_true }
|
17
|
-
specify{ subject.respond_to?(:
|
18
|
-
specify{ subject.respond_to?(:
|
19
|
-
specify{ subject.respond_to?(:
|
20
|
-
specify{ subject.respond_to?(:
|
21
|
-
specify{ subject.respond_to?(:
|
22
|
-
specify{ subject.respond_to?(:
|
23
|
-
specify{ subject.respond_to?(:
|
18
|
+
specify { subject.respond_to?(:any_callbacks?).should be_true }
|
19
|
+
specify { subject.respond_to?(:request_caller).should be_true }
|
20
|
+
specify { subject.respond_to?(:data_callback).should be_true }
|
21
|
+
specify { subject.respond_to?(:error).should be_true }
|
22
|
+
specify { subject.respond_to?(:fail).should be_true }
|
23
|
+
specify { subject.respond_to?(:complete).should be_true }
|
24
|
+
specify { subject.respond_to?(:parse_response).should be_true }
|
25
|
+
specify { subject.respond_to?(:verify_options!).should be_true }
|
26
|
+
specify { subject.respond_to?(:verify_callbacks).should be_true }
|
24
27
|
end
|
25
28
|
|
26
|
-
|
29
|
+
describe "#any_callbacks?" do
|
27
30
|
|
28
31
|
[:@complete_cb, :@success_cb, :@failure_cb].each do |cb|
|
29
32
|
it "returns true if #{cb} is provided" do
|
@@ -42,7 +45,19 @@ describe Protobuf::Rpc::Connectors::Common do
|
|
42
45
|
|
43
46
|
end
|
44
47
|
|
45
|
-
|
48
|
+
describe '#request_caller' do
|
49
|
+
its(:request_caller) { should eq ::Protobuf.client_host }
|
50
|
+
|
51
|
+
context 'when "client_host" option is given to initializer' do
|
52
|
+
let(:hostname) { 'myhost.myserver.com' }
|
53
|
+
let(:subject_options) { { :client_host => hostname } }
|
54
|
+
|
55
|
+
its(:request_caller) { should_not eq ::Protobuf.client_host }
|
56
|
+
its(:request_caller) { should eq hostname }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "#data_callback" do
|
46
61
|
it "changes state to use the data callback" do
|
47
62
|
subject.data_callback("data")
|
48
63
|
subject.instance_variable_get(:@used_data_callback).should be_true
|
@@ -54,7 +69,28 @@ describe Protobuf::Rpc::Connectors::Common do
|
|
54
69
|
end
|
55
70
|
end
|
56
71
|
|
57
|
-
|
72
|
+
describe '#request_bytes' do
|
73
|
+
let(:service) { Test::ResourceService }
|
74
|
+
let(:method) { :find }
|
75
|
+
let(:request) { '' }
|
76
|
+
let(:client_host) { 'myhost.myservice.com' }
|
77
|
+
let(:subject_options) { { :service => service,
|
78
|
+
:method => method,
|
79
|
+
:request => request,
|
80
|
+
:client_host => client_host } }
|
81
|
+
|
82
|
+
let(:expected) { ::Protobuf::Socketrpc::Request.new({ :service_name => service.name,
|
83
|
+
:method_name => 'find',
|
84
|
+
:request_proto => '',
|
85
|
+
:caller => client_host }) }
|
86
|
+
|
87
|
+
before { subject.stub(:validate_request_type!).and_return(true) }
|
88
|
+
before { subject.should_not_receive(:fail) }
|
89
|
+
|
90
|
+
its(:request_bytes) { should eq expected.serialize_to_string }
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#verify_callbacks" do
|
58
94
|
|
59
95
|
it "sets @failure_cb to #data_callback when no callbacks are defined" do
|
60
96
|
subject.verify_callbacks
|
data/spec/lib/protobuf_spec.rb
CHANGED
@@ -3,6 +3,22 @@ require 'protobuf'
|
|
3
3
|
|
4
4
|
describe ::Protobuf do
|
5
5
|
|
6
|
+
describe '.client_host' do
|
7
|
+
after { ::Protobuf.instance_variable_set(:@_client_host, nil) }
|
8
|
+
|
9
|
+
subject { ::Protobuf.client_host }
|
10
|
+
|
11
|
+
context 'when client_host is not pre-configured' do
|
12
|
+
it { should eq `hostname`.chomp }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when client_host is pre-configured' do
|
16
|
+
let(:hostname) { 'override.myhost.com' }
|
17
|
+
before { ::Protobuf.client_host = hostname }
|
18
|
+
it { should eq hostname }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
describe '.connector_type' do
|
7
23
|
before { described_class.instance_variable_set(:@_connector_type, nil) }
|
8
24
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: protobuf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.5.
|
5
|
+
version: 2.5.2
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- BJ Neilsen
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-12-05 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -338,7 +338,6 @@ files:
|
|
338
338
|
- lib/protobuf/version.rb
|
339
339
|
- lib/protobuf/wire_type.rb
|
340
340
|
- lib/protobuf/zmq.rb
|
341
|
-
- proto/rpc.pb.rb
|
342
341
|
- proto/rpc.proto
|
343
342
|
- protobuf.gemspec
|
344
343
|
- spec/benchmark/tasks.rb
|
data/proto/rpc.pb.rb
DELETED
@@ -1,48 +0,0 @@
|
|
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.optional(::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
|