grpc

package module
v3.11.8 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 28 Imported by: 4

Documentation

Overview

Package grpc provides a gRPC client for micro framework

Package grpc provides a gRPC options

Index

Constants

View Source
const (
	DefaultContentType = "application/grpc"
)

Variables

View Source
var (
	// DefaultPoolMaxStreams maximum streams on a connection
	// (20)
	DefaultPoolMaxStreams = 20

	// DefaultPoolMaxIdle maximum idle conns of a pool
	// (50)
	DefaultPoolMaxIdle = 50

	// 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

	// DefaultServiceConfig enable load balancing
	DefaultServiceConfig = `{"loadBalancingPolicy":"round_robin"}`
)

Functions

func CallOptions

func CallOptions(opts ...grpc.CallOption) client.CallOption

CallOptions to be used to configure gRPC call options

func Codec

func Codec(contentType string, c encoding.Codec) client.Option

gRPC Codec to be used to encode/decode requests for a given content type

func DialOptions

func DialOptions(opts ...grpc.DialOption) client.Option

DialOptions to be used to configure gRPC dial options

func MaxRecvMsgSize

func MaxRecvMsgSize(s int) client.Option

MaxRecvMsgSize set the maximum size of message that client can receive.

func MaxSendMsgSize

func MaxSendMsgSize(s int) client.Option

MaxSendMsgSize set the maximum size of message that client can send.

func NewClient

func NewClient(opts ...client.Option) client.Client

func PoolMaxIdle

func PoolMaxIdle(d int) client.Option

maximum idle conns of a pool

func PoolMaxStreams

func PoolMaxStreams(n int) client.Option

maximum streams on a connectioin

func ServiceConfig added in v3.11.7

func ServiceConfig(str string) client.CallOption

Types

type ConnPool added in v3.11.4

type ConnPool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewConnPool added in v3.11.4

func NewConnPool(size int, ttl time.Duration, idle int, ms int) *ConnPool

func (*ConnPool) Get added in v3.11.4

func (p *ConnPool) Get(ctx context.Context, addr string, opts ...grpc.DialOption) (*PoolConn, error)

func (*ConnPool) Put added in v3.11.4

func (p *ConnPool) Put(conn *PoolConn, err error)

type PoolConn added in v3.11.6

type PoolConn struct {
	*grpc.ClientConn
	// contains filtered or unexported fields
}

func (*PoolConn) Close added in v3.11.6

func (conn *PoolConn) Close()

Jump to

Keyboard shortcuts

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