grpclient

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

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 Call

type Call struct {
	Header                map[string]string
	Trailer               map[string]string
	WaitForReady          bool
	FailFast              bool
	MaxCallRecvMsgSize    int
	MaxCallSendMsgSize    int
	UseCompressor         string
	CallContentSubtype    string
	ForceCodec            string
	MaxRetryRPCBufferSize int
}

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 ClientParameters struct {
	PermitWithoutStream bool          `json:"permit_without_stream"`
	Time                time.Duration `json:"time"`
	Timeout             time.Duration `json:"timeout"`
}

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
}

Directories

Path Synopsis
balancer
p2c

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL