Skip to content

Commit b63f099

Browse files
author
Steve Ramage
committed
PR Feedback for #647 - Error out when both params set
1 parent 18dd02b commit b63f099

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

database/mongodb/mongodb.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const contextWaitTimeout = 5 * time.Second // how long to wait for
3737

3838
var (
3939
ErrNoDatabaseName = fmt.Errorf("no database name")
40-
ErrNilConfig = fmt.Errorf("no config")
40+
ErrNilConfig = fmt.Errorf("no config")
41+
ErrTypoAndNotNonTypoUsed = fmt.Errorf("both x-advisory-lock-timeout-interval and x-advisory-lock-timout-interval were specified")
4142
)
4243

4344
type Mongo struct {
@@ -138,11 +139,17 @@ func (m *Mongo) Open(dsn string) (database.Driver, error) {
138139
return nil, err
139140
}
140141

141-
lockTimeout := unknown.Get("x-advisory-lock-timeout-interval")
142+
lockTimeoutIntervalValue := unknown.Get("x-advisory-lock-timeout-interval")
143+
// The initial release had a typo for this argument but for backwards compatibility sake, we will keep supporting it
144+
// and we will error out if both values are set.
145+
lockTimeoutIntervalValueFromTypo := unknown.Get("x-advisory-lock-timout-interval")
142146

143-
if lockTimeout == "" {
144-
// The initial release had a typo for this argument but for backwards compatibility sake, we will keep supporting it.
145-
lockTimeout = unknown.Get("x-advisory-lock-timout-interval")
147+
lockTimeout := lockTimeoutIntervalValue
148+
149+
if (lockTimeoutIntervalValue != "" && lockTimeoutIntervalValueFromTypo != "") {
150+
return nil, ErrTypoAndNotNonTypoUsed
151+
} else if (lockTimeoutIntervalValueFromTypo != "") {
152+
lockTimeout = lockTimeoutIntervalValueFromTypo
146153
}
147154

148155
maxLockCheckInterval, err := parseInt(lockTimeout, DefaultLockTimeoutInterval)

0 commit comments

Comments
 (0)