request

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConnectionPoolClosedError          = errors.New("connection pool has been closed")
	ConnectionPoolInvalidCapacityError = errors.New("connection pool invalid capacity settings")
	ConnectionPoolEmptyObjectError     = errors.New("Pool.NewClientConnPool is nil, can not create connection")
)

Functions

This section is empty.

Types

type GrpcClientMiddlewareOpts

type GrpcClientMiddlewareOpts struct {
	GrpcClientMiddleware struct {
		StreamInterceptors []grpc.StreamClientInterceptor
		UnaryInterceptors  []grpc.UnaryClientInterceptor
	}
}

type GrpcClientPool

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

func NewGrpcClientPool

func NewGrpcClientPool(name string, poolConf *GrpcClientPoolConf, middlewareOpts *GrpcClientMiddlewareOpts) (*GrpcClientPool, error)

func (*GrpcClientPool) Close

func (p *GrpcClientPool) Close()

func (*GrpcClientPool) GetClientConnect

func (p *GrpcClientPool) GetClientConnect() (*grpc.ClientConn, error)

func (*GrpcClientPool) PutClientConnect

func (p *GrpcClientPool) PutClientConnect(c *grpc.ClientConn)

PutClientConnect 正常回归,返回 connection 是没有错误的

type GrpcClientPoolConf

type GrpcClientPoolConf struct {
	ServerAddress       string `json:"serverAddress" yaml:"serverAddress"`
	ServerPort          uint16 `json:"serverPort" yaml:"serverPort"`
	DisableKeepalive    bool   `json:"disableKeepalive,omitempty" yaml:"disable_keepalive,omitempty"`
	PingIntervalTimeout uint32 `json:"pingIntervalTimeout,omitempty" yaml:"pingIntervalTimeout,omitempty"`
	RetryCount          uint32 `json:"retryCount,omitempty" yaml:"retryCount,omitempty"`
	RetryPerCallTimeout uint32 `json:"retryPerCallTimeout,omitempty" yaml:"retryPerCallTimeout,omitempty"`
}

type Pool

type Pool struct {
	New   func() (interface{}, error) // New create connection function
	Ping  func(interface{}) bool      // Ping check connection is ok
	Close func(interface{})           // Close close connection
	// contains filtered or unexported fields
}

Pool common connection pool

func NewClientConnPool

func NewClientConnPool(initCap, maxCap int, newFunc func() (interface{}, error)) (*Pool, error)

NewClientConnPool New create a pool with capacity

func (*Pool) Destroy

func (p *Pool) Destroy()

Destroy clear all connections

func (*Pool) Get

func (p *Pool) Get() (interface{}, error)

Get returns a conn form store or create one

func (*Pool) Len

func (p *Pool) Len() int

Len returns current connections in pool

func (*Pool) Put

func (p *Pool) Put(v interface{})

Put set back conn into store again

Jump to

Keyboard shortcuts

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