defaults.go raw

   1  /*
   2   *
   3   * Copyright 2018 gRPC authors.
   4   *
   5   * Licensed under the Apache License, Version 2.0 (the "License");
   6   * you may not use this file except in compliance with the License.
   7   * You may obtain a copy of the License at
   8   *
   9   *     http://www.apache.org/licenses/LICENSE-2.0
  10   *
  11   * Unless required by applicable law or agreed to in writing, software
  12   * distributed under the License is distributed on an "AS IS" BASIS,
  13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14   * See the License for the specific language governing permissions and
  15   * limitations under the License.
  16   *
  17   */
  18  
  19  package transport
  20  
  21  import (
  22  	"math"
  23  	"time"
  24  )
  25  
  26  const (
  27  	// The default value of flow control window size in HTTP2 spec.
  28  	defaultWindowSize = 65535
  29  	// The initial window size for flow control.
  30  	initialWindowSize             = defaultWindowSize // for an RPC
  31  	infinity                      = time.Duration(math.MaxInt64)
  32  	defaultClientKeepaliveTime    = infinity
  33  	defaultClientKeepaliveTimeout = 20 * time.Second
  34  	defaultMaxStreamsClient       = 100
  35  	defaultMaxConnectionIdle      = infinity
  36  	defaultMaxConnectionAge       = infinity
  37  	defaultMaxConnectionAgeGrace  = infinity
  38  	defaultServerKeepaliveTime    = 2 * time.Hour
  39  	defaultServerKeepaliveTimeout = 20 * time.Second
  40  	defaultKeepalivePolicyMinTime = 5 * time.Minute
  41  	// max window limit set by HTTP2 Specs.
  42  	maxWindowSize = math.MaxInt32
  43  	// defaultWriteQuota is the default value for number of data
  44  	// bytes that each stream can schedule before some of it being
  45  	// flushed out.
  46  	defaultWriteQuota              = 64 * 1024
  47  	defaultClientMaxHeaderListSize = uint32(16 << 20)
  48  	defaultServerMaxHeaderListSize = uint32(16 << 20)
  49  )
  50  
  51  // MaxStreamID is the upper bound for the stream ID before the current
  52  // transport gracefully closes and new transport is created for subsequent RPCs.
  53  // This is set to 75% of 2^31-1. Streams are identified with an unsigned 31-bit
  54  // integer. It's exported so that tests can override it.
  55  var MaxStreamID = uint32(math.MaxInt32 * 3 / 4)
  56