[#316] locode/boltdb: Add default timeout to open underlying BoltDB instance

Set timeout option of BoltDB Open operation to 3s in order to prevent
indefinite waiting for file lock.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-02-09 18:12:09 +03:00 committed by Leonard Lyubich
parent 97264acb26
commit 04b06ba539
2 changed files with 6 additions and 0 deletions

View file

@ -11,6 +11,8 @@ import (
)
// Open opens underlying BoltDB instance.
//
// Timeout of BoltDB opening is 3s (only for Linux or Darwin).
func (db *DB) Open() error {
// copy-paste from metabase:
// consider universal Open/Close for BoltDB wrappers

View file

@ -2,6 +2,7 @@ package locodebolt
import (
"os"
"time"
"go.etcd.io/bbolt"
)
@ -18,5 +19,8 @@ type options struct {
func defaultOpts() *options {
return &options{
mode: os.ModePerm, // 0777
boltOpts: &bbolt.Options{
Timeout: 3 * time.Second,
},
}
}