def each_remote_read_then_finish
      return enum_for(:each_remote_read_then_finish) unless block_given?
      loop do
        resp =
          begin
            remote_read
          rescue GRPC::Core::CallError => e
            GRPC.logger.warn("In each_remote_read_then_finish: #{e}")
            nil
          end

        break if resp.nil?  # the last response was received
        yield resp
      end

      receive_and_check_status
    ensure
      set_input_stream_done
    end
def each_remote_read_then_finish
      return enum_for(:each_remote_read_then_finish) unless block_given?
      loop do
        resp =
          begin
            remote_read
          rescue GRPC::Core::CallError => e
            GRPC.logger.warn("In each_remote_read_then_finish: #{e}")
            nil
          end

        break if resp.nil?  # the last response was received
        yield resp
      end

      receive_and_check_status
    ensure
      set_input_stream_done
    end
each_remote_read_then_finish passes each response to the given block or
 returns an enumerator of the responses if no block is given.

 It is like each_remote_read, but it blocks on finishing on detecting
 the final message.

 == Enumerator ==

 * #next blocks until the remote endpoint sends a READ or FINISHED
 * for each read, enumerator#next yields the response
 * on status
    * if it's is OK, enumerator#next raises StopException
    * if is not OK, enumerator#next raises RuntimeException

 == Block ==

 * if provided it is executed for each response
 * the call blocks until no more responses are provided

 @return [Enumerator] if no block was given