diff options
author | Valery Piashchynski <[email protected]> | 2021-01-19 18:10:39 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-19 18:10:39 +0300 |
commit | 0ff05b2732b4fd0783f959c94c54d7e39169f979 (patch) | |
tree | f50aa894ea4e5b402332f7f4a13b8c50ebb09126 /plugins/kv | |
parent | 75ebbaac89ce8ebc3ab8de47b16e137844cfcd8a (diff) | |
parent | d8e42927b63a0b102ce10d465a10d64bb6c02e22 (diff) |
Merge pull request #487 from spiral/refactor/server_log_messagesv2.0.0-beta9
refactor(errors, logs): Uniform all errors operations, Update server log level of the server log messages
Diffstat (limited to 'plugins/kv')
-rw-r--r-- | plugins/kv/boltdb/plugin.go | 22 | ||||
-rw-r--r-- | plugins/kv/boltdb/plugin_unit_test.go | 2 | ||||
-rw-r--r-- | plugins/kv/memcached/plugin.go | 16 | ||||
-rw-r--r-- | plugins/kv/memory/plugin.go | 18 |
4 files changed, 29 insertions, 29 deletions
diff --git a/plugins/kv/boltdb/plugin.go b/plugins/kv/boltdb/plugin.go index 6cfc49f6..683d6fc5 100644 --- a/plugins/kv/boltdb/plugin.go +++ b/plugins/kv/boltdb/plugin.go @@ -41,7 +41,7 @@ type Plugin struct { } func (s *Plugin) Init(log logger.Logger, cfg config.Configurer) error { - const op = errors.Op("boltdb plugin init") + const op = errors.Op("boltdb_plugin_init") s.cfg = &Config{} s.cfg.InitDefaults() @@ -62,7 +62,7 @@ func (s *Plugin) Init(log logger.Logger, cfg config.Configurer) error { // create bucket if it does not exist // tx.Commit invokes via the db.Update err = db.Update(func(tx *bolt.Tx) error { - const upOp = errors.Op("boltdb Update") + const upOp = errors.Op("boltdb_plugin_update") _, err = tx.CreateBucketIfNotExists([]byte(s.cfg.Bucket)) if err != nil { return errors.E(op, upOp) @@ -92,7 +92,7 @@ func (s *Plugin) Serve() chan error { } func (s *Plugin) Stop() error { - const op = errors.Op("boltdb stop") + const op = errors.Op("boltdb_plugin_stop") err := s.Close() if err != nil { return errors.E(op, err) @@ -101,7 +101,7 @@ func (s *Plugin) Stop() error { } func (s *Plugin) Has(keys ...string) (map[string]bool, error) { - const op = errors.Op("boltdb Has") + const op = errors.Op("boltdb_plugin_has") s.log.Debug("boltdb HAS method called", "args", keys) if keys == nil { return nil, errors.E(op, errors.NoKeys) @@ -142,7 +142,7 @@ func (s *Plugin) Has(keys ...string) (map[string]bool, error) { // Returns a nil value if the key does not exist or if the key is a nested bucket. // The returned value is only valid for the life of the transaction. func (s *Plugin) Get(key string) ([]byte, error) { - const op = errors.Op("boltdb Get") + const op = errors.Op("boltdb_plugin_get") // to get cases like " " keyTrimmed := strings.TrimSpace(key) if keyTrimmed == "" { @@ -182,7 +182,7 @@ func (s *Plugin) Get(key string) ([]byte, error) { } func (s *Plugin) MGet(keys ...string) (map[string]interface{}, error) { - const op = errors.Op("boltdb MGet") + const op = errors.Op("boltdb_plugin_mget") // defence if keys == nil { return nil, errors.E(op, errors.NoKeys) @@ -234,7 +234,7 @@ func (s *Plugin) MGet(keys ...string) (map[string]interface{}, error) { // Set puts the K/V to the bolt func (s *Plugin) Set(items ...kv.Item) error { - const op = errors.Op("boltdb Set") + const op = errors.Op("boltdb_plugin_set") if items == nil { return errors.E(op, errors.NoKeys) } @@ -297,7 +297,7 @@ func (s *Plugin) Set(items ...kv.Item) error { // Delete all keys from DB func (s *Plugin) Delete(keys ...string) error { - const op = errors.Op("boltdb Delete") + const op = errors.Op("boltdb_plugin_delete") if keys == nil { return errors.E(op, errors.NoKeys) } @@ -344,7 +344,7 @@ func (s *Plugin) Delete(keys ...string) error { // MExpire sets the expiration time to the key // If key already has the expiration time, it will be overwritten func (s *Plugin) MExpire(items ...kv.Item) error { - const op = errors.Op("boltdb MExpire") + const op = errors.Op("boltdb_plugin_mexpire") for i := range items { if items[i].TTL == "" || strings.TrimSpace(items[i].Key) == "" { return errors.E(op, errors.Str("should set timeout and at least one key")) @@ -362,7 +362,7 @@ func (s *Plugin) MExpire(items ...kv.Item) error { } func (s *Plugin) TTL(keys ...string) (map[string]interface{}, error) { - const op = errors.Op("boltdb TTL") + const op = errors.Op("boltdb_plugin_ttl") if keys == nil { return nil, errors.E(op, errors.NoKeys) } @@ -414,7 +414,7 @@ func (s *Plugin) gcPhase() { // calculate current time before loop started to be fair now := time.Now() s.gc.Range(func(key, value interface{}) bool { - const op = errors.Op("gcPhase") + const op = errors.Op("boltdb_plugin_gc") k := key.(string) v, err := time.Parse(time.RFC3339, value.(string)) if err != nil { diff --git a/plugins/kv/boltdb/plugin_unit_test.go b/plugins/kv/boltdb/plugin_unit_test.go index fa12db8c..890736f7 100644 --- a/plugins/kv/boltdb/plugin_unit_test.go +++ b/plugins/kv/boltdb/plugin_unit_test.go @@ -22,7 +22,7 @@ import ( // options *bolt.Options -- boltDB options, such as timeouts, noGrows options and other // bucket string -- name of the bucket to use, should be UTF-8 func newBoltClient(path string, perm os.FileMode, options *bolt.Options, bucket string, ttl time.Duration) (kv.Storage, error) { - const op = errors.Op("newBoltClient") + const op = errors.Op("boltdb_plugin_new_bolt_client") db, err := bolt.Open(path, perm, options) if err != nil { return nil, errors.E(op, err) diff --git a/plugins/kv/memcached/plugin.go b/plugins/kv/memcached/plugin.go index 05159b33..e8b05567 100644 --- a/plugins/kv/memcached/plugin.go +++ b/plugins/kv/memcached/plugin.go @@ -35,7 +35,7 @@ func NewMemcachedClient(url string) kv.Storage { } func (s *Plugin) Init(log logger.Logger, cfg config.Configurer) error { - const op = errors.Op("memcached init") + const op = errors.Op("memcached_plugin_init") s.cfg = &Config{} s.cfg.InitDefaults() err := cfg.UnmarshalKey(PluginName, &s.cfg) @@ -69,7 +69,7 @@ func (s *Plugin) Name() string { // Has checks the key for existence func (s *Plugin) Has(keys ...string) (map[string]bool, error) { - const op = errors.Op("memcached Has") + const op = errors.Op("memcached_plugin_has") if keys == nil { return nil, errors.E(op, errors.NoKeys) } @@ -94,7 +94,7 @@ func (s *Plugin) Has(keys ...string) (map[string]bool, error) { // Get gets the item for the given key. ErrCacheMiss is returned for a // memcache cache miss. The key must be at most 250 bytes in length. func (s *Plugin) Get(key string) ([]byte, error) { - const op = errors.Op("memcached Get") + const op = errors.Op("memcached_plugin_get") // to get cases like " " keyTrimmed := strings.TrimSpace(key) if keyTrimmed == "" { @@ -116,7 +116,7 @@ func (s *Plugin) Get(key string) ([]byte, error) { // return map with key -- string // and map value as value -- []byte func (s *Plugin) MGet(keys ...string) (map[string]interface{}, error) { - const op = errors.Op("memcached MGet") + const op = errors.Op("memcached_plugin_mget") if keys == nil { return nil, errors.E(op, errors.NoKeys) } @@ -151,7 +151,7 @@ func (s *Plugin) MGet(keys ...string) (map[string]interface{}, error) { // time from now (up to 1 month), or an absolute Unix epoch time. // Zero means the Item has no expiration time. func (s *Plugin) Set(items ...kv.Item) error { - const op = errors.Op("memcached Set") + const op = errors.Op("memcached_plugin_set") if items == nil { return errors.E(op, errors.NoKeys) } @@ -192,7 +192,7 @@ func (s *Plugin) Set(items ...kv.Item) error { // time from now (up to 1 month), or an absolute Unix epoch time. // Zero means the Item has no expiration time. func (s *Plugin) MExpire(items ...kv.Item) error { - const op = errors.Op("memcached MExpire") + const op = errors.Op("memcached_plugin_mexpire") for i := range items { if items[i].TTL == "" || strings.TrimSpace(items[i].Key) == "" { return errors.E(op, errors.Str("should set timeout and at least one key")) @@ -219,12 +219,12 @@ func (s *Plugin) MExpire(items ...kv.Item) error { // return time in seconds (int32) for a given keys func (s *Plugin) TTL(keys ...string) (map[string]interface{}, error) { - const op = errors.Op("memcached HTTLas") + const op = errors.Op("memcached_plugin_ttl") return nil, errors.E(op, errors.Str("not valid request for memcached, see https://github.com/memcached/memcached/issues/239")) } func (s *Plugin) Delete(keys ...string) error { - const op = errors.Op("memcached Has") + const op = errors.Op("memcached_plugin_has") if keys == nil { return errors.E(op, errors.NoKeys) } diff --git a/plugins/kv/memory/plugin.go b/plugins/kv/memory/plugin.go index d2d3721b..ddcf88a9 100644 --- a/plugins/kv/memory/plugin.go +++ b/plugins/kv/memory/plugin.go @@ -24,7 +24,7 @@ type Plugin struct { } func (s *Plugin) Init(cfg config.Configurer, log logger.Logger) error { - const op = errors.Op("in-memory storage init") + const op = errors.Op("in_memory_plugin_init") s.cfg = &Config{} s.cfg.InitDefaults() @@ -47,7 +47,7 @@ func (s *Plugin) Serve() chan error { } func (s *Plugin) Stop() error { - const op = errors.Op("in-memory storage stop") + const op = errors.Op("in_memory_plugin_stop") err := s.Close() if err != nil { return errors.E(op, err) @@ -56,7 +56,7 @@ func (s *Plugin) Stop() error { } func (s *Plugin) Has(keys ...string) (map[string]bool, error) { - const op = errors.Op("in-memory storage Has") + const op = errors.Op("in_memory_plugin_has") if keys == nil { return nil, errors.E(op, errors.NoKeys) } @@ -76,7 +76,7 @@ func (s *Plugin) Has(keys ...string) (map[string]bool, error) { } func (s *Plugin) Get(key string) ([]byte, error) { - const op = errors.Op("in-memory storage Get") + const op = errors.Op("in_memory_plugin_get") // to get cases like " " keyTrimmed := strings.TrimSpace(key) if keyTrimmed == "" { @@ -92,7 +92,7 @@ func (s *Plugin) Get(key string) ([]byte, error) { } func (s *Plugin) MGet(keys ...string) (map[string]interface{}, error) { - const op = errors.Op("in-memory storage MGet") + const op = errors.Op("in_memory_plugin_mget") if keys == nil { return nil, errors.E(op, errors.NoKeys) } @@ -117,7 +117,7 @@ func (s *Plugin) MGet(keys ...string) (map[string]interface{}, error) { } func (s *Plugin) Set(items ...kv.Item) error { - const op = errors.Op("in-memory storage Set") + const op = errors.Op("in_memory_plugin_set") if items == nil { return errors.E(op, errors.NoKeys) } @@ -140,7 +140,7 @@ func (s *Plugin) Set(items ...kv.Item) error { // MExpire sets the expiration time to the key // If key already has the expiration time, it will be overwritten func (s *Plugin) MExpire(items ...kv.Item) error { - const op = errors.Op("in-memory storage MExpire") + const op = errors.Op("in_memory_plugin_mexpire") for i := range items { if items[i].TTL == "" || strings.TrimSpace(items[i].Key) == "" { return errors.E(op, errors.Str("should set timeout and at least one key")) @@ -169,7 +169,7 @@ func (s *Plugin) MExpire(items ...kv.Item) error { } func (s *Plugin) TTL(keys ...string) (map[string]interface{}, error) { - const op = errors.Op("in-memory storage TTL") + const op = errors.Op("in_memory_plugin_ttl") if keys == nil { return nil, errors.E(op, errors.NoKeys) } @@ -193,7 +193,7 @@ func (s *Plugin) TTL(keys ...string) (map[string]interface{}, error) { } func (s *Plugin) Delete(keys ...string) error { - const op = errors.Op("in-memory storage Delete") + const op = errors.Op("in_memory_plugin_delete") if keys == nil { return errors.E(op, errors.NoKeys) } |