Skip to content

Commit 53a97dd

Browse files
author
José Carlos
authored
Merge pull request #283 from upper/feature/err-too-many-reconnection-attempts
Feature/err too many reconnection attempts
2 parents 13181c0 + 6d206db commit 53a97dd

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

errors.go

+24-23
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,28 @@ import (
2727

2828
// Error messages.
2929
var (
30-
ErrNoMoreRows = errors.New(`upper: no more rows in this result set`)
31-
ErrNotConnected = errors.New(`upper: you're currently not connected`)
32-
ErrMissingDatabaseName = errors.New(`upper: missing database name`)
33-
ErrMissingCollectionName = errors.New(`upper: missing collection name`)
34-
ErrCollectionDoesNotExist = errors.New(`upper: collection does not exist`)
35-
ErrSockerOrHost = errors.New(`upper: you may connect either to a unix socket or a tcp address, but not both`)
36-
ErrQueryLimitParam = errors.New(`upper: a query can accept only one limit parameter`)
37-
ErrQuerySortParam = errors.New(`upper: a query can accept only one order by parameter`)
38-
ErrQueryOffsetParam = errors.New(`upper: a query can accept only one offset parameter`)
39-
ErrMissingConditions = errors.New(`upper: missing selector conditions`)
40-
ErrUnsupported = errors.New(`upper: this action is currently unsupported on this database`)
41-
ErrUndefined = errors.New(`upper: this value is undefined`)
42-
ErrQueryIsPending = errors.New(`upper: can't execute this instruction while the result set is still open`)
43-
ErrUnsupportedDestination = errors.New(`upper: unsupported destination type`)
44-
ErrUnsupportedType = errors.New(`upper: this type does not support marshaling`)
45-
ErrUnsupportedValue = errors.New(`upper: this value does not support unmarshaling`)
46-
ErrUnknownConditionType = errors.New(`upper: arguments of type %T can't be used as constraints`)
47-
ErrTooManyClients = errors.New(`upper: can't connect to database server: too many clients`)
48-
ErrGivingUpTryingToConnect = errors.New(`upper: giving up trying to connect: too many clients`)
49-
ErrMissingConnURL = errors.New(`upper: missing DSN`)
50-
ErrNotImplemented = errors.New(`upper: call not implemented`)
51-
ErrAlreadyWithinTransaction = errors.New(`upper: already within a transaction`)
52-
ErrServerRefusedConnection = errors.New(`upper: database server refused connection`)
30+
ErrNoMoreRows = errors.New(`upper: no more rows in this result set`)
31+
ErrNotConnected = errors.New(`upper: you're currently not connected`)
32+
ErrMissingDatabaseName = errors.New(`upper: missing database name`)
33+
ErrMissingCollectionName = errors.New(`upper: missing collection name`)
34+
ErrCollectionDoesNotExist = errors.New(`upper: collection does not exist`)
35+
ErrSockerOrHost = errors.New(`upper: you may connect either to a unix socket or a tcp address, but not both`)
36+
ErrQueryLimitParam = errors.New(`upper: a query can accept only one limit parameter`)
37+
ErrQuerySortParam = errors.New(`upper: a query can accept only one order by parameter`)
38+
ErrQueryOffsetParam = errors.New(`upper: a query can accept only one offset parameter`)
39+
ErrMissingConditions = errors.New(`upper: missing selector conditions`)
40+
ErrUnsupported = errors.New(`upper: this action is currently unsupported on this database`)
41+
ErrUndefined = errors.New(`upper: this value is undefined`)
42+
ErrQueryIsPending = errors.New(`upper: can't execute this instruction while the result set is still open`)
43+
ErrUnsupportedDestination = errors.New(`upper: unsupported destination type`)
44+
ErrUnsupportedType = errors.New(`upper: this type does not support marshaling`)
45+
ErrUnsupportedValue = errors.New(`upper: this value does not support unmarshaling`)
46+
ErrUnknownConditionType = errors.New(`upper: arguments of type %T can't be used as constraints`)
47+
ErrTooManyClients = errors.New(`upper: can't connect to database server: too many clients`)
48+
ErrGivingUpTryingToConnect = errors.New(`upper: giving up trying to connect: too many clients`)
49+
ErrTooManyReconnectionAttempts = errors.New(`upper: too many reconnection attempts`)
50+
ErrMissingConnURL = errors.New(`upper: missing DSN`)
51+
ErrNotImplemented = errors.New(`upper: call not implemented`)
52+
ErrAlreadyWithinTransaction = errors.New(`upper: already within a transaction`)
53+
ErrServerRefusedConnection = errors.New(`upper: database server refused connection`)
5354
)

internal/sqladapter/database.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (d *database) connect(connFn func() error) error {
186186

187187
// Attempt to (re)connect
188188
if atomic.AddUint64(&d.connectAttempts, 1) >= maxReconnectionAttempts {
189-
return db.ErrGivingUpTryingToConnect
189+
return db.ErrTooManyReconnectionAttempts
190190
}
191191

192192
waitTime := minConnectionRetryInterval

0 commit comments

Comments
 (0)