Documentation ¶
Overview ¶
Copyright (C) 2019 tisnyo <tisnyo@gmail.com>.
conn is connection pool designed for limiting the size of connections to server. license that can be found in the LICENSE file.
Index ¶
- func GetConnection(server Server) (*net.Conn, interface{}, error)
- func InitServerSettings(server Server, maxConn uint, connMaxIdleTime time.Duration)
- func NewPool(size uint, connFactory *ConnectionFactory) *pool
- func ReturnConnection(server Server, conn *net.Conn, attr interface{}, broken bool)
- func SetDefaultMaxConnIdleTime(connMaxIdleTime time.Duration)
- func SetDefaultMaxConnSize(maxConn uint)
- type ConnectionFactory
- type PlainServer
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConnection ¶
GetConnection tries to get a connection from it's connection pool.
func InitServerSettings ¶
InitServerSettings initializes settings of a server. It is better way that initialize a server settings before getting connections from it's pool.
func NewPool ¶
func NewPool(size uint, connFactory *ConnectionFactory) *pool
NewPool creates a connection pool.
func ReturnConnection ¶
ReturnConnection returns connection to it's connection pool.
func SetDefaultMaxConnIdleTime ¶
SetDefaultMaxConnIdleTime sets default max connection expire time.
func SetDefaultMaxConnSize ¶
func SetDefaultMaxConnSize(maxConn uint)
SetDefaultMaxConnSize sets default max connection size.
Types ¶
type ConnectionFactory ¶
type ConnectionFactory struct { Server Server ConnMaxIdleTime time.Duration DialogTimeout time.Duration }
ConnectionFactory is a factory which creates connection for specific server。
type PlainServer ¶
func (*PlainServer) ConnectionString ¶
func (ps *PlainServer) ConnectionString() string
GetConnectionString gets the server's connection string.
func (*PlainServer) GetHost ¶
func (ps *PlainServer) GetHost() string
GetHost returns server's host.
func (*PlainServer) GetPort ¶
func (ps *PlainServer) GetPort() uint16
GetPort returns server's port.