Sha256: b63eea57362680ce253ee5bdfeb459153163d33846d0f0d426bfed7427b2bc85
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true require 'ds9' module GrpcKit module Session class DrainController module Status NOT_START = 0 STARTED = 1 SENT_SHUTDOWN = 2 SENT_PING = 3 RECV_PING_ACK = 4 SENT_GOAWAY = 5 end def initialize(draining_time = 5) @draining_time = draining_time @status = Status::NOT_START end def start_draining? @status > Status::NOT_START end def start_draining @status = Status::STARTED end # @return [void] def recv_ping_ack if @status == Status::SENT_PING next_step end end # @return [void] def next(session) case @status when Status::NOT_START # next_step when Status::STARTED session.submit_shutdown next_step when Status::SENT_SHUTDOWN session.submit_ping @sent_time = Time.now.to_i next_step when Status::SENT_PING # skip until #recv_ping_ack is called (1RTT) when Status::RECV_PING_ACK if @sent_time && (Time.now.to_i - @sent_time) > @draining_time return end session.submit_goaway(DS9::NO_ERROR, session.last_proc_stream_id) next_step when Status::SENT_GOAWAY # session.shutdown end end private def next_step @status += 1 end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grpc_kit-0.3.8 | lib/grpc_kit/session/drain_controller.rb |
grpc_kit-0.3.7 | lib/grpc_kit/session/drain_controller.rb |
grpc_kit-0.3.6 | lib/grpc_kit/session/drain_controller.rb |