grpc_pool

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeepAliveTime 在此时间后客户端没看到任何活动,将ping服务器
	KeepAliveTime = time.Duration(10) * time.Second

	// KeepAliveTimeout 客户端在ping以后等待的时间
	KeepAliveTimeout = time.Duration(3) * time.Second

	DefaultMaxIdle = 1

	DefaultMaxActive = 64

	DefaultMaxStreamsPerConn = 1000

	DefaultMaxConnIdleSecond = time.Minute

	DefaultMaxWaitConnTime = 20 * time.Millisecond
)

Variables

View Source
var (
	ClosedErr = errors.New("grpc pool has closed")
)
View Source
var ErrorKeyNotExist = errors.New("key not exist")

Functions

func Call added in v0.1.2

func Call(meta *registry.Metadata, fn func(conn grpc.ClientConnInterface) error) error

func Init

func Init(ctx context.Context, opt *Options, connSetting ...registry.GrpcMeta)

func NodeDial

func NodeDial(ctx context.Context, scheme, serviceName string, opts *Options) (*grpc.ClientConn, error)

Types

type Builder

type Builder func() (*grpc.ClientConn, error)

type ClientConn

type ClientConn interface {
	grpc.ClientConnInterface
	// contains filtered or unexported methods
}

type Conn

type Conn interface {
	Value() ClientConn
	Close()
	// contains filtered or unexported methods
}

func GetConnection

func GetConnection(meta registry.GrpcMeta) (Conn, error)

type Option

type Option func(*Options)

Option optional configs

func WithConnIdleSeconds

func WithConnIdleSeconds(seconds time.Duration) Option

func WithDialOptions

func WithDialOptions(opts ...grpc.DialOption) Option

func WithMaxActive

func WithMaxActive(n int) Option

func WithMaxConcurrentStreams

func WithMaxConcurrentStreams(n int) Option

func WithMaxIdle

func WithMaxIdle(n int) Option

func WithWaitConn

func WithWaitConn(millisecond time.Duration) Option

type Options

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

func WithOptions

func WithOptions(opts ...Option) *Options

type Pool

type Pool interface {
	Get() (Conn, error)
	Restore(Conn)
	Close()
}

Jump to

Keyboard shortcuts

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