Class: GrpcKit::Transport::ServerTransport
- Inherits:
-
Object
- Object
- GrpcKit::Transport::ServerTransport
- Includes:
- Packable
- Defined in:
- lib/grpc_kit/transport/server_transport.rb
Instance Method Summary collapse
- #end_write ⇒ void
-
#initialize(control_queue, stream) ⇒ ServerTransport
constructor
A new instance of ServerTransport.
-
#read_data(last: false) ⇒ nil, Array<Boolean,Integer,String>
Nil when closed, tuple of Length-Prefixed-Message.
- #recv_headers ⇒ Hash<String,String>
- #start_response(headers) ⇒ void
- #submit_headers(headers) ⇒ void
- #write_data(buf, last: false) ⇒ void
- #write_trailers(trailer) ⇒ void
Methods included from Packable
Constructor Details
#initialize(control_queue, stream) ⇒ ServerTransport
Returns a new instance of ServerTransport.
12 13 14 15 |
# File 'lib/grpc_kit/transport/server_transport.rb', line 12 def initialize(control_queue, stream) @control_queue = control_queue @stream = stream end |
Instance Method Details
#end_write ⇒ void
This method returns an undefined value.
59 60 61 |
# File 'lib/grpc_kit/transport/server_transport.rb', line 59 def end_write @stream.end_write end |
#read_data(last: false) ⇒ nil, Array<Boolean,Integer,String>
Returns nil when closed, tuple of Length-Prefixed-Message.
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/grpc_kit/transport/server_transport.rb', line 40 def read_data(last: false) data_in_buffer = unpack(nil) return data_in_buffer if data_in_buffer loop do data = recv_data(last: last) return nil unless data = unpack(data) return if end end |
#recv_headers ⇒ Hash<String,String>
64 65 66 |
# File 'lib/grpc_kit/transport/server_transport.rb', line 64 def recv_headers @stream.headers end |
#start_response(headers) ⇒ void
This method returns an undefined value.
19 20 21 22 |
# File 'lib/grpc_kit/transport/server_transport.rb', line 19 def start_response(headers) @control_queue.submit_response(@stream.stream_id, headers) send_data end |
#submit_headers(headers) ⇒ void
This method returns an undefined value.
26 27 28 |
# File 'lib/grpc_kit/transport/server_transport.rb', line 26 def submit_headers(headers) @control_queue.submit_headers(@stream.stream_id, headers) end |
#write_data(buf, last: false) ⇒ void
This method returns an undefined value.
33 34 35 36 |
# File 'lib/grpc_kit/transport/server_transport.rb', line 33 def write_data(buf, last: false) @stream.write_send_data(pack(buf), last: last) send_data end |
#write_trailers(trailer) ⇒ void
This method returns an undefined value.
53 54 55 56 |
# File 'lib/grpc_kit/transport/server_transport.rb', line 53 def write_trailers(trailer) @stream.write_trailers_data(trailer) send_data end |