George Bartolomey
840b20538b
Added frostfs-locode-db CLI utility that can generate and view UN/LOCODE database files. Go package git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/locode copied to this repository to eliminate interdependency between frostfs-node and frostfs-locode-db projects. The process of building database files reduced to starting make command. Signed-off-by: George Bartolomey <george@bh4.ru>
37 lines
587 B
Go
37 lines
587 B
Go
package locodebolt
|
|
|
|
import (
|
|
"io/fs"
|
|
"os"
|
|
"time"
|
|
|
|
"go.etcd.io/bbolt"
|
|
)
|
|
|
|
// Option sets an optional parameter of DB.
|
|
type Option func(*options)
|
|
|
|
type options struct {
|
|
mode fs.FileMode
|
|
|
|
boltOpts *bbolt.Options
|
|
}
|
|
|
|
func defaultOpts() *options {
|
|
return &options{
|
|
mode: os.ModePerm, // 0777
|
|
boltOpts: &bbolt.Options{
|
|
Timeout: 3 * time.Second,
|
|
},
|
|
}
|
|
}
|
|
|
|
// ReadOnly enables read-only mode of the DB.
|
|
//
|
|
// Do not call DB.Put method on instances with
|
|
// this option: the behavior is undefined.
|
|
func ReadOnly() Option {
|
|
return func(o *options) {
|
|
o.boltOpts.ReadOnly = true
|
|
}
|
|
}
|