diff options
author | apolcyn <apolcyn@google.com> | 2018-06-14 20:12:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-14 20:12:11 -0700 |
commit | c65066666f964f656cd6c0f3e0d830c0c12875e8 (patch) | |
tree | 4f193c0be7e7e69770bc0f2f637d872a80b7eeb8 /src/ruby | |
parent | d6616280d37ac057c6d8e8d317a8b62160124c8a (diff) | |
parent | 277d894d7f4f3cfda3d9e2522f845d3161392f35 (diff) |
Merge pull request #15755 from ganmacs/unify-duplicated-method
Unify nearly same methods
Diffstat (limited to 'src/ruby')
-rw-r--r-- | src/ruby/lib/grpc/generic/active_call.rb | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/ruby/lib/grpc/generic/active_call.rb b/src/ruby/lib/grpc/generic/active_call.rb index 8c3aa284aa..86240814bd 100644 --- a/src/ruby/lib/grpc/generic/active_call.rb +++ b/src/ruby/lib/grpc/generic/active_call.rb @@ -116,9 +116,10 @@ module GRPC # Sends the initial metadata that has yet to be sent. # Does nothing if metadata has already been sent for this call. - def send_initial_metadata + def send_initial_metadata(new_metadata = {}) @send_initial_md_mutex.synchronize do return if @metadata_sent + @metadata_to_send.merge!(new_metadata) @metadata_tag = ActiveCall.client_invoke(@call, @metadata_to_send) @metadata_sent = true end @@ -388,7 +389,7 @@ module GRPC def client_streamer(requests, metadata: {}) raise_error_if_already_executed begin - merge_metadata_and_send_if_not_already_sent(metadata) + send_initial_metadata(metadata) requests.each { |r| @call.run_batch(SEND_MESSAGE => @marshal.call(r)) } rescue GRPC::Core::CallError => e receive_and_check_status # check for Cancelled @@ -490,7 +491,7 @@ module GRPC raise_error_if_already_executed # Metadata might have already been sent if this is an operation view begin - merge_metadata_and_send_if_not_already_sent(metadata) + send_initial_metadata(metadata) rescue GRPC::Core::CallError => e batch_result = @call.run_batch(RECV_STATUS_ON_CLIENT => nil) set_input_stream_done @@ -571,15 +572,6 @@ module GRPC end end - def merge_metadata_and_send_if_not_already_sent(new_metadata = {}) - @send_initial_md_mutex.synchronize do - return if @metadata_sent - @metadata_to_send.merge!(new_metadata) - @call.run_batch(SEND_INITIAL_METADATA => @metadata_to_send) - @metadata_sent = true - end - end - def attach_peer_cert(peer_cert) @peer_cert = peer_cert end |