Documentation ¶
Index ¶
- func GetCollection(model interface{}) (*mongo.Collection, error)
- type IMongoPool
- type MongoPool
- func (mp *MongoPool) CreateConnection() (c *mongo.Client, e error)
- func (mp *MongoPool) GetBusyConnectionsCount() int
- func (mp *MongoPool) GetDatabase() (*mongo.Database, error)
- func (mp *MongoPool) GetMaxConnections() int
- func (mp *MongoPool) GetMinConnections() int
- func (mp *MongoPool) GetOpenConnections() []*mongo.Client
- func (mp *MongoPool) GetOpenConnectionsCount() int
- func (mp *MongoPool) GetPoolName() string
- func (mp *MongoPool) GetTimeOut() time.Duration
- func (mp *MongoPool) Init(name string)
- func (mp *MongoPool) SetErrorOnBusy()
- func (mp *MongoPool) SetPoolSize(minConn uint32, maxConn uint32)
- func (mp *MongoPool) TerminateConnection(conn *mongo.Client)
- type MongoPoolError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCollection ¶
func GetCollection(model interface{}) (*mongo.Collection, error)
GetCollection return collection obj
Types ¶
type IMongoPool ¶
type IMongoPool interface { Init(string) CreateConnection() (*mongo.Client, error) GetDatabase() (*mongo.Database, error) GetBusyConnectionsCount() int GetMaxConnections() int GetMinConnections() int GetOpenConnections() []*mongo.Client GetOpenConnectionsCount() int GetPoolName() string GetTimeOut() time.Duration SetErrorOnBusy() SetPoolSize(uint32, uint32) TerminateConnection(*mongo.Client) }
IMongoPool mongo db pooling class's interface
func GetMongoPool ¶
func GetMongoPool(name ...string) IMongoPool
GetMongoPool get mongo pool instace
type MongoPool ¶
type MongoPool struct {
// contains filtered or unexported fields
}
MongoPool mongo db pooling class
func (*MongoPool) CreateConnection ¶
CreateConnection create or get a connect
func (*MongoPool) GetBusyConnectionsCount ¶
GetBusyConnectionsCount return no of busy connections
func (*MongoPool) GetDatabase ¶
GetDatabase return database obj
func (*MongoPool) GetMaxConnections ¶
GetMaxConnections return no of max connections
func (*MongoPool) GetMinConnections ¶
GetMinConnections return no of min connections
func (*MongoPool) GetOpenConnections ¶
GetOpenConnections return no of open connections
func (*MongoPool) GetOpenConnectionsCount ¶
GetOpenConnectionsCount return no of open connections
func (*MongoPool) GetPoolName ¶
GetPoolName return pool name
func (*MongoPool) GetTimeOut ¶
GetTimeOut return timeout
func (*MongoPool) SetErrorOnBusy ¶
func (mp *MongoPool) SetErrorOnBusy()
SetErrorOnBusy return error when all connection are busy
func (*MongoPool) SetPoolSize ¶
SetPoolSize set the pool size
func (*MongoPool) TerminateConnection ¶
TerminateConnection terminate the connection
type MongoPoolError ¶
MongoPoolError MongoPool error
func (*MongoPoolError) Error ¶
func (e *MongoPoolError) Error() string