Explorar el Código

Add 5 seconds timeout for bolt

Jiajie Chen hace 5 años
padre
commit
16e458f354
Se han modificado 1 ficheros con 4 adiciones y 1 borrados
  1. 4 1
      manager/db.go

+ 4 - 1
manager/db.go

@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"strings"
+	"time"
 
 	"github.com/boltdb/bolt"
 
@@ -26,7 +27,9 @@ type dbAdapter interface {
 
 func makeDBAdapter(dbType string, dbFile string) (dbAdapter, error) {
 	if dbType == "bolt" {
-		innerDB, err := bolt.Open(dbFile, 0600, nil)
+		innerDB, err := bolt.Open(dbFile, 0600, &bolt.Options{
+			Timeout: 5 * time.Second,
+		})
 		if err != nil {
 			return nil, err
 		}