Documentation ¶
Overview ¶
Package dbreaker provides a simple "circuit breaker" wrapper for sql.DB connections
It wraps the original driver with a new driver that exposes a Disable function that can toggle access to the database. This allows for stopping db operations for maintence purposes without modifying application code
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrContext = fmt.Errorf("context operations are not supported")
ErrContext is returned when context operations are not supported
var ErrDown = fmt.Errorf("database is down")
ErrDown is returned when circuit breaker is enabled
Functions ¶
This section is empty.
Types ¶
type Breaker ¶
type Breaker struct {
// contains filtered or unexported fields
}
Breaker is an sql.Driver that can block access to the database
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn implements the sql.Driver.Conn interface
func (*Conn) Close ¶
Close invalidates and potentially stops any current prepared statements and transactions, marking this connection as no longer in use.
Because the sql package maintains a free pool of connections and only calls Close when there's a surplus of idle connections, it shouldn't be necessary for drivers to do their own connection caching.