mirror of
https://github.com/docker/docs.git
synced 2026-11-05 00:14:17 +03:00
Merge pull request #726 from docker/rethink-timeouts
Increase timeout for RethinkDB (default is 0), remove extra wait
This commit is contained in:
@@ -3,25 +3,22 @@ package rethinkdb
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"gopkg.in/dancannon/gorethink.v2"
|
||||
)
|
||||
|
||||
// Wait for 60 seconds maximum on Wait() calls for rethink
|
||||
var timeoutOpt = gorethink.WaitOpts{Timeout: time.Minute.Seconds()}
|
||||
|
||||
func makeDB(session *gorethink.Session, name string) error {
|
||||
_, err := gorethink.DBCreate(name).RunWrite(session)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "already exists") {
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
resp, err := gorethink.DB(name).Wait().Run(session)
|
||||
if resp != nil {
|
||||
resp.Close()
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -41,7 +38,7 @@ func (t Table) term(dbName string) gorethink.Term {
|
||||
}
|
||||
|
||||
func (t Table) wait(session *gorethink.Session, dbName string) error {
|
||||
resp, err := t.term(dbName).Wait().Run(session)
|
||||
resp, err := t.term(dbName).Wait(timeoutOpt).Run(session)
|
||||
|
||||
if resp != nil {
|
||||
resp.Close()
|
||||
|
||||
Reference in New Issue
Block a user