Sha256: 8dc66545dc8bead86bc4761f303e9c1bf94282753974afa8e565107c5caee5d1

Contents?: true

Size: 1.04 KB

Versions: 11

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'grpc_kit/call'
require 'grpc_kit/calls'

module GrpcKit
  module Calls::Server
    class BidiStreamer < GrpcKit::Call
      include Enumerable

      attr_reader :outgoing_initial_metadata, :outgoing_trailing_metadata
      alias incoming_metadata metadata

      def initialize(*)
        super

        @outgoing_initial_metadata = {}
        @outgoing_trailing_metadata = {}
      end

      # @param data [Object] request message
      # @return [void]
      def send_msg(data)
        @stream.send_msg(
          data,
          @codec,
          initial_metadata: @outgoing_initial_metadata,
          trailing_metadata: @outgoing_trailing_metadata,
          limit_size: @config.max_send_message_size,
        )
      end

      # @return [Object] response object
      def recv
        @stream.recv_msg(@codec, limit_size: @config.max_receive_message_size)
      end

      # @yieldparam response [Object] each response object of bidi streaming RPC
      def each
        loop { yield(recv) }
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
grpc_kit-0.3.9 lib/grpc_kit/calls/server_bidi_streamer.rb
grpc_kit-0.3.8 lib/grpc_kit/calls/server_bidi_streamer.rb
grpc_kit-0.3.7 lib/grpc_kit/calls/server_bidi_streamer.rb
grpc_kit-0.3.6 lib/grpc_kit/calls/server_bidi_streamer.rb
grpc_kit-0.3.5 lib/grpc_kit/calls/server_bidi_streamer.rb
grpc_kit-0.3.4 lib/grpc_kit/calls/server_bidi_streamer.rb
grpc_kit-0.3.3 lib/grpc_kit/calls/server_bidi_streamer.rb
grpc_kit-0.3.2 lib/grpc_kit/calls/server_bidi_streamer.rb
grpc_kit-0.3.1 lib/grpc_kit/calls/server_bidi_streamer.rb
grpc_kit-0.3.0 lib/grpc_kit/calls/server_bidi_streamer.rb
grpc_kit-0.2.1 lib/grpc_kit/calls/server_bidi_streamer.rb