Skip to content

Commit

Permalink
Merge pull request #283 from upper/feature/err-too-many-reconnection-…
Browse files Browse the repository at this point in the history
…attempts

Feature/err too many reconnection attempts
  • Loading branch information
José Carlos authored Nov 10, 2016
2 parents 13181c0 + 6d206db commit 53a97dd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
47 changes: 24 additions & 23 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,28 @@ import (

// Error messages.
var (
ErrNoMoreRows = errors.New(`upper: no more rows in this result set`)
ErrNotConnected = errors.New(`upper: you're currently not connected`)
ErrMissingDatabaseName = errors.New(`upper: missing database name`)
ErrMissingCollectionName = errors.New(`upper: missing collection name`)
ErrCollectionDoesNotExist = errors.New(`upper: collection does not exist`)
ErrSockerOrHost = errors.New(`upper: you may connect either to a unix socket or a tcp address, but not both`)
ErrQueryLimitParam = errors.New(`upper: a query can accept only one limit parameter`)
ErrQuerySortParam = errors.New(`upper: a query can accept only one order by parameter`)
ErrQueryOffsetParam = errors.New(`upper: a query can accept only one offset parameter`)
ErrMissingConditions = errors.New(`upper: missing selector conditions`)
ErrUnsupported = errors.New(`upper: this action is currently unsupported on this database`)
ErrUndefined = errors.New(`upper: this value is undefined`)
ErrQueryIsPending = errors.New(`upper: can't execute this instruction while the result set is still open`)
ErrUnsupportedDestination = errors.New(`upper: unsupported destination type`)
ErrUnsupportedType = errors.New(`upper: this type does not support marshaling`)
ErrUnsupportedValue = errors.New(`upper: this value does not support unmarshaling`)
ErrUnknownConditionType = errors.New(`upper: arguments of type %T can't be used as constraints`)
ErrTooManyClients = errors.New(`upper: can't connect to database server: too many clients`)
ErrGivingUpTryingToConnect = errors.New(`upper: giving up trying to connect: too many clients`)
ErrMissingConnURL = errors.New(`upper: missing DSN`)
ErrNotImplemented = errors.New(`upper: call not implemented`)
ErrAlreadyWithinTransaction = errors.New(`upper: already within a transaction`)
ErrServerRefusedConnection = errors.New(`upper: database server refused connection`)
ErrNoMoreRows = errors.New(`upper: no more rows in this result set`)
ErrNotConnected = errors.New(`upper: you're currently not connected`)
ErrMissingDatabaseName = errors.New(`upper: missing database name`)
ErrMissingCollectionName = errors.New(`upper: missing collection name`)
ErrCollectionDoesNotExist = errors.New(`upper: collection does not exist`)
ErrSockerOrHost = errors.New(`upper: you may connect either to a unix socket or a tcp address, but not both`)
ErrQueryLimitParam = errors.New(`upper: a query can accept only one limit parameter`)
ErrQuerySortParam = errors.New(`upper: a query can accept only one order by parameter`)
ErrQueryOffsetParam = errors.New(`upper: a query can accept only one offset parameter`)
ErrMissingConditions = errors.New(`upper: missing selector conditions`)
ErrUnsupported = errors.New(`upper: this action is currently unsupported on this database`)
ErrUndefined = errors.New(`upper: this value is undefined`)
ErrQueryIsPending = errors.New(`upper: can't execute this instruction while the result set is still open`)
ErrUnsupportedDestination = errors.New(`upper: unsupported destination type`)
ErrUnsupportedType = errors.New(`upper: this type does not support marshaling`)
ErrUnsupportedValue = errors.New(`upper: this value does not support unmarshaling`)
ErrUnknownConditionType = errors.New(`upper: arguments of type %T can't be used as constraints`)
ErrTooManyClients = errors.New(`upper: can't connect to database server: too many clients`)
ErrGivingUpTryingToConnect = errors.New(`upper: giving up trying to connect: too many clients`)
ErrTooManyReconnectionAttempts = errors.New(`upper: too many reconnection attempts`)
ErrMissingConnURL = errors.New(`upper: missing DSN`)
ErrNotImplemented = errors.New(`upper: call not implemented`)
ErrAlreadyWithinTransaction = errors.New(`upper: already within a transaction`)
ErrServerRefusedConnection = errors.New(`upper: database server refused connection`)
)
2 changes: 1 addition & 1 deletion internal/sqladapter/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (d *database) connect(connFn func() error) error {

// Attempt to (re)connect
if atomic.AddUint64(&d.connectAttempts, 1) >= maxReconnectionAttempts {
return db.ErrGivingUpTryingToConnect
return db.ErrTooManyReconnectionAttempts
}

waitTime := minConnectionRetryInterval
Expand Down

0 comments on commit 53a97dd

Please sign in to comment.