thriftPool

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHECK_INTERVAL = 60 //清除超时连接间隔
)

Variables

View Source
var (
	ErrOverMax          = errors.New("连接超过设置的最大连接数")
	ErrInvalidConn      = errors.New("Client回收时变成nil")
	ErrPoolClosed       = errors.New("连接池已经被关闭")
	ErrSocketDisconnect = errors.New("客户端socket连接已断开")
)

error

Functions

This section is empty.

Types

type IdleClient

type IdleClient struct {
	Socket *thrift.TSocket
	Client interface{}
}

func (*IdleClient) Check

func (c *IdleClient) Check() bool

func (*IdleClient) LocalAddr

func (c *IdleClient) LocalAddr() net.Addr

func (*IdleClient) RemoteAddr

func (c *IdleClient) RemoteAddr() net.Addr

func (*IdleClient) SetConnTimeout

func (c *IdleClient) SetConnTimeout(connTimeout uint32)

type MapPool

type MapPool struct {
	Dial  ThriftDial
	Close ThriftClientClose
	// contains filtered or unexported fields
}

func NewMapPool

func NewMapPool(maxConn, connTimeout, idleTimeout uint32,
	dial ThriftDial, closeFunc ThriftClientClose) *MapPool

func (*MapPool) Get

func (mp *MapPool) Get(ip, port string) *ThriftPool

func (*MapPool) Release

func (mp *MapPool) Release(ip, port string) error

func (*MapPool) ReleaseAll

func (mp *MapPool) ReleaseAll()

type ThriftClientClose

type ThriftClientClose func(c *IdleClient) error

type ThriftDial

type ThriftDial func(ip, port string, connTimeout time.Duration) (*IdleClient, error)

type ThriftPool

type ThriftPool struct {
	Dial  ThriftDial
	Close ThriftClientClose
	// contains filtered or unexported fields
}

func NewThriftPool

func NewThriftPool(ip, port string,
	maxConn, connTimeout, idleTimeout uint32,
	dial ThriftDial, closeFunc ThriftClientClose) *ThriftPool

func (*ThriftPool) CheckTimeout

func (p *ThriftPool) CheckTimeout()

func (*ThriftPool) ClearConn

func (p *ThriftPool) ClearConn()

func (*ThriftPool) CloseErrConn

func (p *ThriftPool) CloseErrConn(client *IdleClient)

func (*ThriftPool) Get

func (p *ThriftPool) Get() (*IdleClient, error)

func (*ThriftPool) GetConnCount

func (p *ThriftPool) GetConnCount() uint32

func (*ThriftPool) GetIdleCount

func (p *ThriftPool) GetIdleCount() uint32

func (*ThriftPool) Put

func (p *ThriftPool) Put(client *IdleClient) error

func (*ThriftPool) Recover

func (p *ThriftPool) Recover()

func (*ThriftPool) Release

func (p *ThriftPool) Release()

Jump to

Keyboard shortcuts

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