Class: GrpcKit::Session::ServerSession
- Inherits:
-
DS9::Server
- Object
- DS9::Server
- GrpcKit::Session::ServerSession
- Extended by:
- Forwardable
- Defined in:
- lib/grpc_kit/session/server_session.rb
Instance Method Summary collapse
- #drain ⇒ void
-
#initialize(io, dispatcher) ⇒ ServerSession
constructor
A new instance of ServerSession.
-
#run_once ⇒ bool
Return session can continue.
- #shutdown ⇒ void
- #start ⇒ void
Constructor Details
#initialize(io, dispatcher) ⇒ ServerSession
Returns a new instance of ServerSession.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/grpc_kit/session/server_session.rb', line 18 def initialize(io, dispatcher) super() # initialize DS9::Session @io = io @streams = {} @stop = false @inflights = [] @drain_controller = GrpcKit::Session::DrainController.new @control_queue = GrpcKit::Session::ControlQueue.new @dispatcher = dispatcher end |
Instance Method Details
#drain ⇒ void
This method returns an undefined value.
79 80 81 |
# File 'lib/grpc_kit/session/server_session.rb', line 79 def drain @drain_controller.start_draining end |
#run_once ⇒ bool
Return session can continue
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/grpc_kit/session/server_session.rb', line 50 def run_once if @stop || !(want_read? || want_write?) # it could be called twice @streams.each_value(&:close) return false end if @drain_controller.start_draining? @drain_controller.next(self) end rs, ws = @io.select if !rs.empty? && want_read? do_read end if !ws.empty? && want_write? send end true rescue Errno::ECONNRESET, IOError => e GrpcKit.logger.error(e.) shutdown false end |
#shutdown ⇒ void
This method returns an undefined value.
84 85 86 87 88 89 |
# File 'lib/grpc_kit/session/server_session.rb', line 84 def shutdown stop @io.close rescue StandardError => e GrpcKit.logger.error(e) end |
#start ⇒ void
This method returns an undefined value.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/grpc_kit/session/server_session.rb', line 31 def start loop do invoke if @streams.empty? unless @io.wait_readable shutdown break end end continue = run_once break unless continue end ensure GrpcKit.logger.debug('Finish server session') end |