cpool

package
v0.0.0-...-76e78dc Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxConn = fmt.Errorf("maximum connections reached")

Functions

This section is empty.

Types

type ClusteredConnPool

type ClusteredConnPool struct {
	sync.RWMutex
	M map[string]*ConnPool
}

ConnPools Manager

func CreateClusteredConnPool

func CreateClusteredConnPool(connPoolFactory func(addr string) *ConnPool, cluster []string) *ClusteredConnPool

func (*ClusteredConnPool) Call

func (this *ClusteredConnPool) Call(addr string, arg interface{}) (interface{}, error)

同步发送, 完成发送或超时后 才能返回

func (*ClusteredConnPool) Destroy

func (this *ClusteredConnPool) Destroy()

func (*ClusteredConnPool) Get

func (this *ClusteredConnPool) Get(address string) (*ConnPool, bool)

func (*ClusteredConnPool) Stats

func (this *ClusteredConnPool) Stats() []*ConnPoolStats

type ConnPool

type ConnPool struct {
	sync.RWMutex

	Name        string
	Address     string
	MaxConns    int
	MaxIdle     int
	ConnTimeout int
	CallTimeout int
	Cnt         int64
	New         func(name string, pool *ConnPool) (PoolClient, error)
	// contains filtered or unexported fields
}

func NewConnPool

func NewConnPool(name string, address string, maxConns int, maxIdle int, connTimeout int, callTimeout int, new func(string, *ConnPool) (PoolClient, error)) *ConnPool

func (*ConnPool) Call

func (this *ConnPool) Call(arg interface{}) (interface{}, error)

func (*ConnPool) Destroy

func (this *ConnPool) Destroy()

func (*ConnPool) Fetch

func (this *ConnPool) Fetch() (PoolClient, error)

func (*ConnPool) ForceClose

func (this *ConnPool) ForceClose(conn PoolClient)

func (*ConnPool) Release

func (this *ConnPool) Release(conn PoolClient)

func (*ConnPool) Stats

func (this *ConnPool) Stats() *ConnPoolStats

type ConnPoolStats

type ConnPoolStats struct {
	Name   string
	Count  int64
	Active int
	All    int
	Free   int
}

func (*ConnPoolStats) String

func (this *ConnPoolStats) String() string

type PoolClient

type PoolClient interface {
	io.Closer
	Name() string
	Call(arg interface{}) (interface{}, error)
	Closed() bool
}

Jump to

Keyboard shortcuts

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