Skip to content
This repository has been archived by the owner on Jul 22, 2018. It is now read-only.

add MarkUnreusable to pooled connection #7

Merged
merged 4 commits into from Mar 25, 2015
Merged

Conversation

collinmsn
Copy link
Contributor

It's desirable to close the connection directly because an error, for example timeout, occurred on the connection.

conn, err := pool.Get()
defer conn.Close()

if err := UseConn(conn); err != nil {
conn.MarkUnreusable()
}

This patch adds this feature.

to make it possible to discard unreusable connections
@charl
Copy link

charl commented Mar 25, 2015

@collinmsn is might read easier as:

  conn.MarkAsDead()

Or:

conn.MarkUnusable()

@collinmsn
Copy link
Contributor Author

OK, I prefer Unusable.

return p.c.put(p.Conn)
}

// MarkUnreusable() marks the connection is not reusable.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment needs to be updated too. Also can you extend the comment to let the user know that the connection will be not put into the pool anymore?

@fatih
Copy link
Owner

fatih commented Mar 25, 2015

Unusable is better yeah, thanks for changing it.

fatih added a commit that referenced this pull request Mar 25, 2015
add MarkUnreusable to pooled connection
@fatih fatih merged commit cba550e into fatih:v2.0.0 Mar 25, 2015
@fatih
Copy link
Owner

fatih commented Mar 25, 2015

Thanks @collinmsn 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants