All checks were successful
Build / Build Components (1.19) (pull_request) Successful in 2m15s
Tests and linters / Tests (1.19) (pull_request) Successful in 2m22s
Tests and linters / Tests (1.20) (pull_request) Successful in 2m50s
Build / Build Components (1.20) (pull_request) Successful in 12m23s
Tests and linters / Tests with -race (pull_request) Successful in 5m47s
Vulncheck / Vulncheck (pull_request) Successful in 1m6s
Tests and linters / Lint (pull_request) Successful in 14m38s
Tests and linters / Staticcheck (pull_request) Successful in 6m14s
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
20 lines
493 B
Go
20 lines
493 B
Go
package writecachebbolt
|
|
|
|
import (
|
|
"io/fs"
|
|
"os"
|
|
"path/filepath"
|
|
"time"
|
|
|
|
"go.etcd.io/bbolt"
|
|
)
|
|
|
|
// OpenDB opens BoltDB instance for write-cache. Opens in read-only mode if ro is true.
|
|
func OpenDB(p string, ro bool, openFile func(string, int, fs.FileMode) (*os.File, error)) (*bbolt.DB, error) {
|
|
return bbolt.Open(filepath.Join(p, dbName), os.ModePerm, &bbolt.Options{
|
|
NoFreelistSync: true,
|
|
ReadOnly: ro,
|
|
Timeout: 100 * time.Millisecond,
|
|
OpenFile: openFile,
|
|
})
|
|
}
|