Sha256: 7f77c80746af77433563010611c3e6d1d332609e70a852592862a4801df3aba5
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true require 'grpc_kit/transport/packable' module GrpcKit module Transports class ServerTransport include GrpcKit::Transport::Packable # @params session [GrpcKit::Sessions::ServerSession] # @params stream [GrpcKit::Session::Stream] def initialize(session, stream) @session = session @stream = stream end def each loop do data = recv return if data.nil? yield(data) end end def send_response(headers) @session.submit_response(@stream.stream_id, headers) end def write_data(buf, last: false) @stream.write_send_data(pack(buf), last: last) end def read_data(last: false) unpack(read(last: last)) end def write_trailers_data(trailer) @stream.write_trailers_data(trailer) @stream.end_write end def recv_headers @stream.headers end private def read(last: false) loop do data = @stream.read_recv_data(last: last) return data unless data.empty? if @stream.close_remote? # it do not receive data which we need, it may receive invalid grpc-status unless @stream.end_read? return nil end return nil end @session.run_once end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grpc_kit-0.1.4 | lib/grpc_kit/transports/server_transport.rb |