Class: GrpcKit::Session::Stream

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/grpc_kit/session/stream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream_id:) ⇒ Stream

Returns a new instance of Stream.

Parameters:

  • stream_id (Integer)


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/grpc_kit/session/stream.rb', line 21

def initialize(stream_id:)
  @stream_id = stream_id
  @end_read_stream = false
  @headers = GrpcKit::Session::Headers.new
  @pending_send_data = GrpcKit::Session::SendBuffer.new
  @pending_recv_data = GrpcKit::Session::RecvBuffer.new

  @inflight = false
  @trailer_data = {}
  @status = GrpcKit::Session::StreamStatus.new
  @draining = false
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



17
18
19
# File 'lib/grpc_kit/session/stream.rb', line 17

def headers
  @headers
end

#inflightObject

Returns the value of attribute inflight.



18
19
20
# File 'lib/grpc_kit/session/stream.rb', line 18

def inflight
  @inflight
end

#pending_recv_dataObject (readonly)

Returns the value of attribute pending_recv_data.



17
18
19
# File 'lib/grpc_kit/session/stream.rb', line 17

def pending_recv_data
  @pending_recv_data
end

#pending_send_dataObject (readonly)

Returns the value of attribute pending_send_data.



17
18
19
# File 'lib/grpc_kit/session/stream.rb', line 17

def pending_send_data
  @pending_send_data
end

#statusObject (readonly)

Returns the value of attribute status.



17
18
19
# File 'lib/grpc_kit/session/stream.rb', line 17

def status
  @status
end

#stream_idObject

Returns the value of attribute stream_id.



18
19
20
# File 'lib/grpc_kit/session/stream.rb', line 18

def stream_id
  @stream_id
end

#trailer_dataObject (readonly)

Returns the value of attribute trailer_data.



17
18
19
# File 'lib/grpc_kit/session/stream.rb', line 17

def trailer_data
  @trailer_data
end

Instance Method Details

#add_header(name, value) ⇒ void

This method returns an undefined value.

Parameters:

  • name (String)
  • value (String)


70
71
72
# File 'lib/grpc_kit/session/stream.rb', line 70

def add_header(name, value)
  @headers.add(name, value)
end

#closeObject



76
77
78
79
# File 'lib/grpc_kit/session/stream.rb', line 76

def close
  status.close
  pending_recv_data.close
end

#close_remoteObject



81
82
83
84
# File 'lib/grpc_kit/session/stream.rb', line 81

def close_remote
  status.close_remote
  pending_recv_data.close
end

#drainvoid

This method returns an undefined value.



43
44
45
# File 'lib/grpc_kit/session/stream.rb', line 43

def drain
  @draining = true
end

#end_readObject



38
39
40
# File 'lib/grpc_kit/session/stream.rb', line 38

def end_read
  @pending_recv_data.end_read
end

#end_writeObject



34
35
36
# File 'lib/grpc_kit/session/stream.rb', line 34

def end_write
  @pending_send_data.end_write
end

#read_recv_data(last: false, blocking:) ⇒ void

This method returns an undefined value.

Parameters:

  • last (Boolean) (defaults to: false)
  • blocking (Boolean)


63
64
65
# File 'lib/grpc_kit/session/stream.rb', line 63

def read_recv_data(last: false, blocking:)
  @pending_recv_data.read(last: last, blocking: blocking)
end

#write_send_data(data, last: false) ⇒ void

This method returns an undefined value.

Parameters:

  • data (String)
  • last (Boolean) (defaults to: false)


56
57
58
# File 'lib/grpc_kit/session/stream.rb', line 56

def write_send_data(data, last: false)
  @pending_send_data.write(data, last: last)
end

#write_trailers_data(tarilers) ⇒ void

This method returns an undefined value.

Parameters:

  • tarilers (Hash<String,String>)


49
50
51
# File 'lib/grpc_kit/session/stream.rb', line 49

def write_trailers_data(tarilers)
  @trailer_data = tarilers
end