Class: GrpcKit::Session::StreamStatus

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeStreamStatus

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

#closevoid

This method returns an undefined value.



42
43
44
# File 'lib/grpc_kit/session/stream_status.rb', line 42

def close
  @status = CLOSE
end

#close?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/grpc_kit/session/stream_status.rb', line 57

def close?
  @status == CLOSE
end

#close_localvoid

This method returns an undefined value.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/grpc_kit/session/stream_status.rb', line 16

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

Returns:

  • (Boolean)


47
48
49
# File 'lib/grpc_kit/session/stream_status.rb', line 47

def close_local?
  (@status == HALF_CLOSE_LOCAL) || close?
end

#close_remotevoid

This method returns an undefined value.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/grpc_kit/session/stream_status.rb', line 29

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

Returns:

  • (Boolean)


52
53
54
# File 'lib/grpc_kit/session/stream_status.rb', line 52

def close_remote?
  (@status == HALF_CLOSE_REMOTE) || close?
end