grpcc

package
v0.1.26 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: Apache-2.0 Imports: 28 Imported by: 9

Documentation

Index

Constants

View Source
const (
	Name = "grpcc"

	// DefaultTimeout 默认的连接超时时间
	DefaultTimeout = 2 * time.Second
)

Variables

This section is empty.

Functions

func HealthCheck

func HealthCheck(srv string, conn *grpc.ClientConn) error

func InitClient added in v0.1.26

func InitClient(srv string, opts ...func(cfg *Cfg))

func WithAfterDial added in v0.1.26

func WithAfterDial(fn func()) func(cfg *Cfg)

func WithBeforeDial added in v0.1.26

func WithBeforeDial(fn func()) func(cfg *Cfg)

func WithClientType added in v0.1.26

func WithClientType(typ interface{}) func(cfg *Cfg)

func WithDirect added in v0.1.26

func WithDirect() func(cfg *Cfg)

func WithDiscov added in v0.1.26

func WithDiscov() func(cfg *Cfg)

func WithDns added in v0.1.26

func WithDns() func(cfg *Cfg)

func WithK8s added in v0.1.26

func WithK8s() func(cfg *Cfg)

func WithNewClientFunc added in v0.1.26

func WithNewClientFunc(fn func(cc grpc.ClientConnInterface) interface{}) func(cfg *Cfg)

func WithRegistry added in v0.1.26

func WithRegistry(name string) func(cfg *Cfg)

Types

type Cfg

type Cfg struct {
	MaxMsgSize           int           `json:"max_msg_size"`
	Codec                string        `json:"codec"`
	Compressor           string        `json:"compressor"`
	Decompressor         string        `json:"decompressor"`
	Balancer             string        `json:"balancer"`
	BackoffMaxDelay      time.Duration `json:"backoff_max_delay"`
	Timeout              time.Duration `json:"timeout"`
	DialTimeout          time.Duration `json:"dial_timeout"`
	MaxDelay             time.Duration `json:"max_delay"`
	UserAgent            string        `json:"user_agent"`
	Authority            string        `json:"authority"`
	ChannelzParentID     int64         `json:"channelz_parent_id"`
	DisableServiceConfig bool          `json:"disable_service_config"`
	DefaultServiceConfig string        `json:"default_service_config"`
	DisableRetry         bool          `json:"disable_retry"`

	// MaxHeaderListSize 每次调用允许发送的header的最大条数
	MaxHeaderListSize  uint32 `json:"max_header_list_size"`
	DisableHealthCheck bool   `json:"disable_health_check"`
	BalancerName       string `json:"balancer_name"`
	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 maximum message that Client can receive (4 MB).
	MaxRecvMsgSize     int                            `json:"max_recv_msg_size"`
	NoProxy            bool                           `json:"no_proxy"`
	Proxy              bool                           `json:"proxy"`
	ConnectParams      connectParams                  `json:"connect_params"`
	ClientParameters   clientParameters               `json:"client_parameters"`
	Call               callParameters                 `json:"call"`
	Middlewares        []service.Middleware           `json:"-"`
	DialOptions        []grpc.DialOption              `json:"-"`
	UnaryInterceptors  []grpc.UnaryClientInterceptor  `json:"-"`
	StreamInterceptors []grpc.StreamClientInterceptor `json:"-"`
	Service            string                         `json:"-"`
	Group              string                         `json:"-"`
	// contains filtered or unexported fields
}

Cfg ...

func DefaultCfg

func DefaultCfg(opts ...func(cfg *Cfg)) Cfg

func (Cfg) Check added in v0.1.26

func (t Cfg) Check() error

func (Cfg) GetReg added in v0.1.26

func (t Cfg) GetReg() string

func (Cfg) ToOpts

func (t Cfg) ToOpts() []grpc.DialOption

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New added in v0.1.26

func New(service string, opts ...func(cfg *Cfg)) *Client

func NewClient added in v0.1.26

func NewClient(service string, cfg Cfg) *Client

NewClient build grpc client

func (*Client) Get

func (t *Client) Get() (_ grpc.ClientConnInterface, gErr error)

Get new grpc Client

func (*Client) Invoke

func (t *Client) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...grpc.CallOption) error

func (*Client) NewStream

func (t *Client) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)

Directories

Path Synopsis
lb
p2c

Jump to

Keyboard shortcuts

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