Sha256: 1cd2fac4983fbffc838262fbe43bd2c48a048820729d0822e403bff310dba3dc

Contents?: true

Size: 860 Bytes

Versions: 4

Compression:

Stored size: 860 Bytes

Contents

# frozen_string_literal: true

require 'ds9'

module GrpcKit
  module Session
    class DrainController
      def initialize
        @sent_shutdown_notice = false
        @goaway_sent = false
        @after_one_rtt = false
        # @sent_ping = false
      end

      def recv_ping_ack
        @after_one_rtt = true
      end

      def call(session)
        if @goaway_sent
        # session.shutdown
        elsif @sent_shutdown_notice && @after_one_rtt
          session.submit_goaway(DS9::NO_ERROR, session.last_proc_stream_id)
          @goaway_sent = true
        # elsif @sent_shutdown_notice && !@after_one_rtt && !@sent_ping
        # @sent_ping = true
        elsif !@sent_shutdown_notice
          session.submit_shutdown
          @sent_shutdown_notice = true
          session.submit_ping # wait for 1 RTT
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grpc_kit-0.1.8 lib/grpc_kit/session/drain_controller.rb
grpc_kit-0.1.7 lib/grpc_kit/session/drain_controller.rb
grpc_kit-0.1.6 lib/grpc_kit/session/drain_controller.rb
grpc_kit-0.1.5 lib/grpc_kit/session/drain_controller.rb