Class: GrpcKit::Transport::ServerTransport

Inherits:
Object
  • Object
show all
Includes:
Packable
Defined in:
lib/grpc_kit/transport/server_transport.rb

Instance Method Summary collapse

Methods included from Packable

#pack, #unpack, #unpacker

Constructor Details

#initialize(session, stream) ⇒ ServerTransport

Returns a new instance of ServerTransport


12
13
14
15
# File 'lib/grpc_kit/transport/server_transport.rb', line 12

def initialize(session, stream)
  @session = session
  @stream = stream
end

Instance Method Details

#end_writevoid

This method returns an undefined value.


52
53
54
# File 'lib/grpc_kit/transport/server_transport.rb', line 52

def end_write
  @stream.end_write
end

#read_data(last: false) ⇒ nil, String

Parameters:

  • last (Boolean)

Returns:

  • (nil, String)

40
41
42
# File 'lib/grpc_kit/transport/server_transport.rb', line 40

def read_data(last: false)
  unpack(recv_data(last: last))
end

#recv_headersHash<String,String>

Returns:

  • (Hash<String,String>)

57
58
59
# File 'lib/grpc_kit/transport/server_transport.rb', line 57

def recv_headers
  @stream.headers
end

#start_response(headers) ⇒ void

This method returns an undefined value.

Parameters:

  • headers (Hash<String, String>)

19
20
21
22
# File 'lib/grpc_kit/transport/server_transport.rb', line 19

def start_response(headers)
  @session.submit_response(@stream.stream_id, headers)
  send_data
end

#submit_headers(headers) ⇒ void

This method returns an undefined value.

Parameters:

  • headers (Hash<String, String>)

26
27
28
# File 'lib/grpc_kit/transport/server_transport.rb', line 26

def submit_headers(headers)
  @session.submit_headers(@stream.stream_id, headers)
end

#write_data(buf, last: false) ⇒ void

This method returns an undefined value.

Parameters:

  • buf (String)
  • last (Boolean)

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(last: last)
end

#write_trailers(trailer) ⇒ void

This method returns an undefined value.

Parameters:

  • trailer (Hash<String, String>)

46
47
48
49
# File 'lib/grpc_kit/transport/server_transport.rb', line 46

def write_trailers(trailer)
  @stream.write_trailers_data(trailer)
  send_data(last: true)
end