Documentation
¶
Index ¶
Constants ¶
View Source
const ( Name = "grpc_client" // DefaultTimeout 默认的连接超时时间 DefaultTimeout = 3 * time.Second // DefaultMaxRecvMsgSize maximum message that client can receive // (4 MB). DefaultMaxRecvMsgSize = 1024 * 1024 * 4 // DefaultMaxSendMsgSize maximum message that client can send // (4 MB). DefaultMaxSendMsgSize = 1024 * 1024 * 4 Timeout = 3 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func Get ¶
func Get(service string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
Get new grpc client
func New ¶
func New(service string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
Types ¶
type BackoffConfig ¶
type BackoffConfig struct {
// BaseDelay is the amount of time to backoff after the first failure.
BaseDelay time.Duration
// Multiplier is the factor with which to multiply backoffs after a
// failed retry. Should ideally be greater than 1.
Multiplier float64
// Jitter is the factor with which backoffs are randomized.
Jitter float64
// MaxDelay is the upper bound of backoff delay.
MaxDelay time.Duration
}
BackoffConfig defines the configuration options for backoff.
type Cfg ¶
type Cfg struct {
Registry string `json:"registry"`
MaxMsgSize int
// grpc.encoding
Codec string
Compressor string
Decompressor string
Balancer string
BackoffMaxDelay time.Duration
Timeout time.Duration
DialTimeout time.Duration
UserAgent string
ConnectParams ConnectParams
Authority string
ChannelzParentID int64
DisableServiceConfig bool
DefaultServiceConfig string
DisableRetry bool
MaxHeaderListSize uint32
DisableHealthCheck bool
Insecure bool `json:"insecure"`
Block bool `json:"block"`
IdleNum uint32 `json:"idle_num"`
WriteBuffer int `json:"write_buffer"`
ReadBuffer int `json:"read_buffer"`
WindowSize int32 `json:"window_size"`
ConnWindowSize int32 `json:"conn_window_size"`
MaxRecvMsgSize int `json:"max_recv_msg_size"`
MaxDelay time.Duration `json:"max_delay"`
NoProxy bool
Proxy bool `json:"proxy"`
ClientParameters ClientParameters `json:"params"`
Call Call `json:"call"`
}
WithContextDialer
func GetDefaultCfg ¶
func GetDefaultCfg() Cfg
type ClientParameters ¶
type ConnectParams ¶
type ConnectParams struct {
// Backoff specifies the configuration options for connection backoff.
Backoff BackoffConfig
// MinConnectTimeout is the minimum amount of time we are willing to give a
// connection to complete.
MinConnectTimeout time.Duration
}
Click to show internal directories.
Click to hide internal directories.