Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/kep-w/MongoDB-Connection-Pool

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/kep-w/MongoDB-Connection-Pool

  • v0.0.0-20210301033619-eb7f520c0782
  • Source
  • Go
  • Socket score

Version published
Created
Source

Golang MongoDB connection pool

Efficiently control the number of database connections and realize automatic connection management

Details:

Provide connection pool management through struct MongoPool.

The connection pool parameters are set during initialization, including:

  • cached channel for storing connections, and the cache controls the maximum number of idle connections.
  • Database address,
  • timeout period,
  • maximum number of connections.

for example:

func init() {
	once.Do(func() {
		DBPool = &MongoPool{
			pool:        make(chan *mongo.Client, 10), 
			connections: 0,                            
			timeout:     10 * time.Second,
			uri:         "mongodb://user:password@127.0.0.1:27017/dbname",
			poolSize:    10, 
		}
	})
}

Note: You can use function once.Do to ensure that the connection pool is only created once.

FAQs

Package last updated on 01 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc