Documentation ¶
Overview ¶
Package sqlcon provides helpers for dealing with SQL connectivity.
Index ¶
- Variables
- func FinalizeDSN(l *logrusx.Logger, dsn string) string
- func GetDriverName(dsn string) string
- func HandleError(err error) error
- func HelpMessage() string
- func ParseConnectionOptions(l *logrusx.Logger, dsn string) (maxConns int, maxIdleConns int, maxConnLifetime, maxIdleConnTime time.Duration, ...)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUniqueViolation is returned when^a SQL INSERT / UPDATE command returns a conflict. ErrUniqueViolation = &herodot.DefaultError{ CodeField: http.StatusConflict, GRPCCodeField: codes.AlreadyExists, StatusField: http.StatusText(http.StatusConflict), ErrorField: "Unable to insert or update resource because a resource with that value exists already", } // ErrNoRows is returned when a SQL SELECT statement returns no rows. ErrNoRows = &herodot.DefaultError{ CodeField: http.StatusNotFound, GRPCCodeField: codes.NotFound, StatusField: http.StatusText(http.StatusNotFound), ErrorField: "Unable to locate the resource", } // ErrConcurrentUpdate is returned when the database is unable to serialize access due to a concurrent update. ErrConcurrentUpdate = &herodot.DefaultError{ CodeField: http.StatusBadRequest, GRPCCodeField: codes.Aborted, StatusField: http.StatusText(http.StatusBadRequest), ErrorField: "Unable to serialize access due to a concurrent update in another session", } )
Functions ¶
func FinalizeDSN ¶ added in v0.0.116
FinalizeDSN will return a finalized DSN URI.
func GetDriverName ¶ added in v0.0.73
GetDriverName returns the driver name of a given DSN.
func HandleError ¶
HandleError returns the right sqlcon.Err* depending on the input error.
func HelpMessage ¶
func HelpMessage() string
HelpMessage returns a string explaining how to set up SQL using environment variables.
func ParseConnectionOptions ¶ added in v0.0.84
func ParseConnectionOptions(l *logrusx.Logger, dsn string) (maxConns int, maxIdleConns int, maxConnLifetime, maxIdleConnTime time.Duration, cleanedDSN string)
ParseConnectionOptions parses values for max_conns, max_idle_conns, max_conn_lifetime from DSNs. It also returns the URI without those query parameters.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.