pool

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPoolCapacityNumber = 10
	MinPoolCapacityNumber = 0
	MaxStreamNumber       = 10
	MinStreamNumber       = 0
)

Variables

View Source
var (
	//ErrClosed 连接池已经关闭Error
	ErrClosed = errors.New("pool is closed")
	// RejectForNil 拒绝操作
	RejectForNil = errors.New("connection is nil. rejecting")
	// ErrPoolFull 连接池已满
	ErrPoolFull = errors.New("pool is full, can not put")
	// ErrPoolEmpty 连接池已空
	ErrPoolEmpty = errors.New("pool is empty, can not get")
	// ErrTargets 错误的端口号
	ErrTargets = errors.New("dail target is not exist")
)

Functions

This section is empty.

Types

type Config

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

func NewConfigWithPath

func NewConfigWithPath(path string) *Config

func (*Config) DailTimeout

func (c *Config) DailTimeout() time.Duration

func (*Config) GetDailStringByIndex

func (c *Config) GetDailStringByIndex(index int) string

func (*Config) IsTls

func (c *Config) IsTls() bool

func (*Config) MaxIdle

func (c *Config) MaxIdle() int

func (*Config) MaxLifetime

func (c *Config) MaxLifetime() time.Duration

func (*Config) MaxRecvMsgSize

func (c *Config) MaxRecvMsgSize() int

func (*Config) MaxSendMsgSize

func (c *Config) MaxSendMsgSize() int

func (*Config) MaxStreamLifetime

func (c *Config) MaxStreamLifetime() time.Duration

func (*Config) Namespace

func (c *Config) Namespace() string

func (*Config) NodeIPs

func (c *Config) NodeIPs() []string

func (*Config) SetDailTimeout

func (c *Config) SetDailTimeout(dailTimeout time.Duration)

func (*Config) SetMaxIdle

func (c *Config) SetMaxIdle(maxIdle int)

func (*Config) SetMaxLifetime

func (c *Config) SetMaxLifetime(maxLifetime time.Duration)

func (*Config) SetMaxRecvMsgSize

func (c *Config) SetMaxRecvMsgSize(maxRecvMsgSize int)

func (*Config) SetMaxSendMsgSize

func (c *Config) SetMaxSendMsgSize(maxSendMsgSize int)

func (*Config) SetTargets

func (c *Config) SetTargets(targets []string)

func (*Config) Targets

func (c *Config) Targets() []string

func (*Config) TlsDomain

func (c *Config) TlsDomain() string

func (*Config) TlscaPath

func (c *Config) TlscaPath() string

func (*Config) Viper

func (c *Config) Viper() *viper.Viper

type GrpcStream

type GrpcStream interface {
	Send(*api.CommonReq) error
	Recv() (*api.CommonRes, error)
	grpc.ClientStream
}

type IdleStream

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

func (*IdleStream) Close

func (c *IdleStream) Close() error

func (*IdleStream) GetStream

func (id *IdleStream) GetStream() GrpcStream

func (*IdleStream) ResetTime

func (id *IdleStream) ResetTime()

type StreamPool

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

func NewStreamWithContext

func NewStreamWithContext(aliveTime time.Duration, num int, factory func(ctx context.Context) (GrpcStream, error)) (*StreamPool, error)

func (*StreamPool) Capacity

func (s *StreamPool) Capacity() int32

func (*StreamPool) Close

func (s *StreamPool) Close() error

func (*StreamPool) Get

func (s *StreamPool) Get() (*IdleStream, error)

func (*StreamPool) Put

func (s *StreamPool) Put(stream *IdleStream) error

Jump to

Keyboard shortcuts

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