Sha256: 693364e0242669ca68619dd653cb188dff03f546b17b7ff1cfec288b956d7b48

Contents?: true

Size: 906 Bytes

Versions: 7

Compression:

Stored size: 906 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

      # @return [void]
      def recv_ping_ack
        @after_one_rtt = true
      end

      # @return [void]
      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

7 entries across 7 versions & 1 rubygems

Version Path
grpc_kit-0.2.0 lib/grpc_kit/session/drain_controller.rb
grpc_kit-0.1.14 lib/grpc_kit/session/drain_controller.rb
grpc_kit-0.1.13 lib/grpc_kit/session/drain_controller.rb
grpc_kit-0.1.12 lib/grpc_kit/session/drain_controller.rb
grpc_kit-0.1.11 lib/grpc_kit/session/drain_controller.rb
grpc_kit-0.1.10 lib/grpc_kit/session/drain_controller.rb
grpc_kit-0.1.9 lib/grpc_kit/session/drain_controller.rb