Skip to content

Commit b617229

Browse files
authored
Merge pull request #395 from minond/mm/separate-base-request-fields
Creating request fields in new Base#request_fields method.
2 parents e8a2bf6 + 8d6c7ce commit b617229

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

lib/protobuf/rpc/connectors/base.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,7 @@ def ping_port_enabled?
139139

140140
def request_bytes
141141
validate_request_type!
142-
fields = { :service_name => @options[:service].name,
143-
:method_name => @options[:method].to_s,
144-
:request_proto => @options[:request],
145-
:caller => request_caller }
146-
147-
return ::Protobuf::Socketrpc::Request.encode(fields)
142+
return ::Protobuf::Socketrpc::Request.encode(request_fields)
148143
rescue => e
149144
failure(:INVALID_REQUEST_PROTO, "Could not set request proto: #{e.message}")
150145
end
@@ -153,6 +148,13 @@ def request_caller
153148
@options[:client_host] || ::Protobuf.client_host
154149
end
155150

151+
def request_fields
152+
{ :service_name => @options[:service].name,
153+
:method_name => @options[:method].to_s,
154+
:request_proto => @options[:request],
155+
:caller => request_caller }
156+
end
157+
156158
def send_request
157159
fail 'If you inherit a Connector from Base you must implement send_request'
158160
end

0 commit comments

Comments
 (0)