simple_conn_pool

package
v0.0.0-...-ff3f51f Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2015 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type ConnPool

type ConnPool struct {
	sync.RWMutex

	Name     string
	Address  string
	MaxConns int32
	MaxIdle  int32
	Cnt      int64
	Ts       int64
	New      func(name string) (NConn, error)
	// contains filtered or unexported fields
}

func NewConnPool

func NewConnPool(name string, address string, maxConns int32, maxIdle int32) *ConnPool

func (*ConnPool) Destroy

func (this *ConnPool) Destroy()

func (*ConnPool) Fetch

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

func (*ConnPool) ForceClose

func (this *ConnPool) ForceClose(conn NConn)

func (*ConnPool) Proc

func (this *ConnPool) Proc() string

func (*ConnPool) Release

func (this *ConnPool) Release(conn NConn)

type NConn

type NConn interface {
	io.Closer
	Name() string
	Closed() bool
}

type RpcClient

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

RpcCient, 要实现io.Closer接口

func (RpcClient) Call

func (this RpcClient) Call(method string, args interface{}, reply interface{}) error

func (RpcClient) Close

func (this RpcClient) Close() error

func (RpcClient) Closed

func (this RpcClient) Closed() bool

func (RpcClient) Name

func (this RpcClient) Name() string

type SafeRpcConnPools

type SafeRpcConnPools struct {
	sync.RWMutex
	M           map[string]*ConnPool
	MaxConns    int32
	MaxIdle     int32
	ConnTimeout int32
	CallTimeout int32
}

ConnPools Manager

func CreateSafeRpcConnPools

func CreateSafeRpcConnPools(maxConns, maxIdle, connTimeout, callTimeout int32, cluster []string) *SafeRpcConnPools

func (*SafeRpcConnPools) Destroy

func (this *SafeRpcConnPools) Destroy()

func (*SafeRpcConnPools) Get

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

func (*SafeRpcConnPools) Proc

func (this *SafeRpcConnPools) Proc() []string

Jump to

Keyboard shortcuts

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