aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby/lib
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2016-07-07 15:52:27 -0700
committerGravatar murgatroid99 <mlumish@google.com>2016-07-07 15:52:27 -0700
commite69f088cd973e61da445eddae61c67de6edbca17 (patch)
tree993494ea87fa59ecf4436216923e9f8f4ffa67dc /src/ruby/lib
parent2cbe7542853a99931c5bd8d8576bd527c1ad023a (diff)
Split incoming initial and trailing metadata in Ruby calls
Diffstat (limited to 'src/ruby/lib')
-rw-r--r--src/ruby/lib/grpc/generic/active_call.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/ruby/lib/grpc/generic/active_call.rb b/src/ruby/lib/grpc/generic/active_call.rb
index a3ac0d48a3..5c142fb161 100644
--- a/src/ruby/lib/grpc/generic/active_call.rb
+++ b/src/ruby/lib/grpc/generic/active_call.rb
@@ -43,8 +43,7 @@ class Struct
GRPC.logger.debug("Failing with status #{status}")
# raise BadStatus, propagating the metadata if present.
md = status.metadata
- with_sym_keys = Hash[md.each_pair.collect { |x, y| [x.to_sym, y] }]
- fail GRPC::BadStatus.new(status.code, status.details, with_sym_keys)
+ fail GRPC::BadStatus.new(status.code, status.details, md)
end
status
end
@@ -61,7 +60,7 @@ module GRPC
extend Forwardable
attr_reader(:deadline)
def_delegators :@call, :cancel, :metadata, :write_flag, :write_flag=,
- :peer, :peer_cert
+ :peer, :peer_cert, :trailing_metadata
# client_invoke begins a client invocation.
#
@@ -158,6 +157,9 @@ module GRPC
ops[RECV_STATUS_ON_CLIENT] = nil if assert_finished
batch_result = @call.run_batch(ops)
return unless assert_finished
+ unless batch_result.status.nil?
+ @call.trailing_metadata = batch_result.status.metadata
+ end
@call.status = batch_result.status
op_is_done
batch_result.check_status
@@ -169,11 +171,7 @@ module GRPC
def finished
batch_result = @call.run_batch(RECV_STATUS_ON_CLIENT => nil)
unless batch_result.status.nil?
- if @call.metadata.nil?
- @call.metadata = batch_result.status.metadata
- else
- @call.metadata.merge!(batch_result.status.metadata)
- end
+ @call.trailing_metadata = batch_result.status.metadata
end
@call.status = batch_result.status
op_is_done
@@ -456,17 +454,19 @@ module GRPC
# SingleReqView limits access to an ActiveCall's methods for use in server
# handlers that receive just one request.
SingleReqView = view_class(:cancelled, :deadline, :metadata,
- :output_metadata, :peer, :peer_cert)
+ :output_metadata, :peer, :peer_cert,
+ :trailing_metadata)
# MultiReqView limits access to an ActiveCall's methods for use in
# server client_streamer handlers.
MultiReqView = view_class(:cancelled, :deadline, :each_queued_msg,
- :each_remote_read, :metadata, :output_metadata)
+ :each_remote_read, :metadata, :output_metadata,
+ :trailing_metadata)
# Operation limits access to an ActiveCall's methods for use as
# a Operation on the client.
Operation = view_class(:cancel, :cancelled, :deadline, :execute,
:metadata, :status, :start_call, :wait, :write_flag,
- :write_flag=)
+ :write_flag=, :trailing_metadata)
end
end