Skip to content

Connection pooling for multithread apps #72

Closed Answered by sijms
hmmftg asked this question in Q&A
Discussion options

You must be logged in to vote

it also seem that the package database/sql internally support connection pooling thus you can use the connection object safely between threads in multi-thread application

see this code from official Golang package site here

type Connector interface {
    // Connect returns a connection to the database.
    // Connect may return a cached connection (one previously
    // closed), but doing so is unnecessary; the sql package
    // maintains a pool of idle connections for efficient re-use.
    //
    // The provided context.Context is for dialing purposes only
    // (see net.DialContext) and should not be stored or used for
    // other purposes. A default timeout should still be used
    …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@hmmftg
Comment options

Answer selected by sijms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants