Class: GrpcKit::Session::StreamStatus
- Inherits:
-
Object
- Object
- GrpcKit::Session::StreamStatus
- Defined in:
- lib/grpc_kit/session/stream_status.rb
Constant Summary collapse
- OPEN =
0- CLOSE =
1- HALF_CLOSE_REMOTE =
2- HALF_CLOSE_LOCAL =
3
Instance Method Summary collapse
- #close ⇒ Object
- #close? ⇒ Boolean
- #close_local ⇒ Object
- #close_local? ⇒ Boolean
- #close_remote ⇒ Object
- #close_remote? ⇒ Boolean
-
#initialize ⇒ StreamStatus
constructor
A new instance of StreamStatus.
Constructor Details
#initialize ⇒ StreamStatus
Returns a new instance of StreamStatus.
11 12 13 |
# File 'lib/grpc_kit/session/stream_status.rb', line 11 def initialize @status = OPEN end |
Instance Method Details
#close ⇒ Object
39 40 41 |
# File 'lib/grpc_kit/session/stream_status.rb', line 39 def close @status = CLOSE end |
#close? ⇒ Boolean
51 52 53 |
# File 'lib/grpc_kit/session/stream_status.rb', line 51 def close? @status == CLOSE end |
#close_local ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/grpc_kit/session/stream_status.rb', line 15 def close_local if @status == OPEN @status = HALF_CLOSE_LOCAL elsif @status == HALF_CLOSE_REMOTE @status = CLOSE elsif @status == HALF_CLOSE_LOCAL # nothing else raise 'stream is already closed' end end |
#close_local? ⇒ Boolean
43 44 45 |
# File 'lib/grpc_kit/session/stream_status.rb', line 43 def close_local? (@status == HALF_CLOSE_LOCAL) || close? end |
#close_remote ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/grpc_kit/session/stream_status.rb', line 27 def close_remote if @status == OPEN @status = HALF_CLOSE_REMOTE elsif @status == HALF_CLOSE_LOCAL @status = CLOSE elsif @status == HALF_CLOSE_REMOTE # nothing else raise 'stream is already closed' end end |
#close_remote? ⇒ Boolean
47 48 49 |
# File 'lib/grpc_kit/session/stream_status.rb', line 47 def close_remote? (@status == HALF_CLOSE_REMOTE) || close? end |