github.com/cloudwego/kitex@v0.9.0/pkg/remote/trans/nphttp2/grpc/defaults.go (about)

     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   * This file may have been modified by CloudWeGo authors. All CloudWeGo
    18   * Modifications are Copyright 2021 CloudWeGo Authors.
    19   */
    20  
    21  package grpc
    22  
    23  import (
    24  	"math"
    25  	"time"
    26  
    27  	"github.com/cloudwego/kitex"
    28  )
    29  
    30  const (
    31  	// The default value of flow control window size in HTTP2 spec.
    32  	// Warning: please don't modify the value of defaultWindowSize, otherwise may cause compatibility problems.
    33  	defaultWindowSize = uint32(65535) // 64KB
    34  	// The initial window size for flow control.
    35  	initialWindowSize = defaultWindowSize // for an RPC
    36  	// Infinity means unset duration
    37  	Infinity                     = time.Duration(math.MaxInt64)
    38  	defaultMaxStreamsClient      = 100
    39  	defaultMaxConnectionIdle     = Infinity
    40  	defaultMaxConnectionAge      = Infinity
    41  	defaultMaxConnectionAgeGrace = Infinity
    42  	// keepalive
    43  	defaultClientKeepaliveTime    = Infinity
    44  	defaultClientKeepaliveTimeout = 20 * time.Second
    45  	defaultServerKeepaliveTime    = 2 * time.Hour
    46  	defaultServerKeepaliveTimeout = 20 * time.Second
    47  	defaultKeepalivePolicyMinTime = 5 * time.Minute
    48  	// max window limit set by HTTP2 Specs.
    49  	maxWindowSize = math.MaxInt32
    50  	// defaultWriteQuota is the default value for number of data
    51  	// bytes that each stream can schedule before some of it being
    52  	// flushed out.
    53  	defaultWriteQuota              = 64 * 1024
    54  	defaultClientMaxHeaderListSize = uint32(16 << 20)
    55  	defaultServerMaxHeaderListSize = uint32(16 << 20)
    56  	// http2IOBufSize specifies the buffer size for sending frames.
    57  	defaultWriteBufferSize = uint32(32 * 1024)
    58  	// http2IOBufSize specifies the buffer size for receiving frames.
    59  	defaultReadBufferSize = uint32(32 * 1024)
    60  
    61  	defaultUserAgent = "kitex/" + kitex.Version
    62  )
    63  
    64  const (
    65  	// KeepaliveMinPingTime is the minimum ping interval.
    66  	// This must be 10s by default, but tests may wish to set it lower for convenience.
    67  	KeepaliveMinPingTime = 10 * time.Second
    68  )