Put timeout on opening bolt
parent
4416a7e4b3
commit
d04ced1e33
5
init.sh
5
init.sh
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
port=57017
|
port=57017
|
||||||
|
|
||||||
if ! curl -sS localhost:$port > /dev/null; then
|
if false && ! curl -sS localhost:$port > /dev/null; then
|
||||||
prefix=/tmp/whodunit.db
|
prefix=/tmp/whodunit.db
|
||||||
mkdir -p $prefix/data
|
mkdir -p $prefix/data
|
||||||
mongod \
|
mongod \
|
||||||
|
|
@ -26,3 +26,6 @@ remove() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export DBURI=${DB_URI:-"mongodb://localhost:$port"}
|
export DBURI=${DB_URI:-"mongodb://localhost:$port"}
|
||||||
|
|
||||||
|
export DRIVERTYPE=boltdb
|
||||||
|
export DBURI=$(mktemp)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/boltdb/bolt"
|
"github.com/boltdb/bolt"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
|
@ -25,7 +26,9 @@ type BoltDB struct {
|
||||||
|
|
||||||
func NewBoltDB() *BoltDB {
|
func NewBoltDB() *BoltDB {
|
||||||
config := config.New()
|
config := config.New()
|
||||||
db, err := bolt.Open(config.DBURI, os.ModePerm, nil)
|
db, err := bolt.Open(config.DBURI, os.ModePerm, &bolt.Options{
|
||||||
|
Timeout: time.Second * 3,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ func TestJSON(t *testing.T) {
|
||||||
}
|
}
|
||||||
os.Args = os.Args[:1]
|
os.Args = os.Args[:1]
|
||||||
|
|
||||||
|
t.Logf("config: %+v", config.New())
|
||||||
|
|
||||||
g := storage.NewGraph()
|
g := storage.NewGraph()
|
||||||
ones := fillDB(t, g)
|
ones := fillDB(t, g)
|
||||||
want := ones[len(ones)-1]
|
want := ones[len(ones)-1]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue