diff options
Diffstat (limited to 'plugins/kv/boltdb')
-rw-r--r-- | plugins/kv/boltdb/config.go | 23 | ||||
-rw-r--r-- | plugins/kv/boltdb/plugin.go | 8 |
2 files changed, 24 insertions, 7 deletions
diff --git a/plugins/kv/boltdb/config.go b/plugins/kv/boltdb/config.go index ea0e3375..ebe73c25 100644 --- a/plugins/kv/boltdb/config.go +++ b/plugins/kv/boltdb/config.go @@ -16,9 +16,22 @@ type Config struct { // InitDefaults initializes default values for the boltdb func (s *Config) InitDefaults() { - s.Dir = "." // current dir - s.Bucket = "rr" // default bucket name - s.File = "rr.db" // default file name - s.Permissions = 0777 // free for all - s.Interval = 60 // default is 60 seconds timeout + if s.Dir == "" { + s.Dir = "." // current dir + } + if s.Bucket == "" { + s.Bucket = "rr" // default bucket name + } + + if s.File == "" { + s.File = "rr.db" // default file name + } + + if s.Permissions == 0 { + s.Permissions = 777 // free for all + } + + if s.Interval == 0 { + s.Interval = 60 // default is 60 seconds timeout + } } diff --git a/plugins/kv/boltdb/plugin.go b/plugins/kv/boltdb/plugin.go index 683d6fc5..1e3d2c34 100644 --- a/plugins/kv/boltdb/plugin.go +++ b/plugins/kv/boltdb/plugin.go @@ -42,15 +42,19 @@ type Plugin struct { func (s *Plugin) Init(log logger.Logger, cfg config.Configurer) error { const op = errors.Op("boltdb_plugin_init") - s.cfg = &Config{} - s.cfg.InitDefaults() + if !cfg.Has(PluginName) { + return errors.E(op, errors.Disabled) + } err := cfg.UnmarshalKey(PluginName, &s.cfg) if err != nil { return errors.E(op, errors.Disabled, err) } + // add default values + s.cfg.InitDefaults() + // set the logger s.log = log |