diff options
author | Valery Piashchynski <[email protected]> | 2021-06-24 15:31:15 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-06-24 15:31:15 +0300 |
commit | fdff0ffe41b45d0e919eccc683104987898a4faf (patch) | |
tree | 79b242b1af7d283eedfb0ac124e48c5fa47ef461 /plugins/kv/rpc.go | |
parent | ce53a8e149b76f15e8a5dd88ac3b953798d57e8b (diff) |
- Add Clear method to the storages
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/kv/rpc.go')
-rw-r--r-- | plugins/kv/rpc.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/kv/rpc.go b/plugins/kv/rpc.go index af763600..3f7ba97c 100644 --- a/plugins/kv/rpc.go +++ b/plugins/kv/rpc.go @@ -161,3 +161,19 @@ func (r *rpc) Delete(in *kvv1.Request, _ *kvv1.Response) error { return errors.E(op, errors.Errorf("no such storage: %s", in.GetStorage())) } + +// Clear clean the storage +func (r *rpc) Clear(in *kvv1.Request, _ *kvv1.Response) error { + const op = errors.Op("rcp_delete") + + if st, exists := r.storages[in.GetStorage()]; exists { + err := st.Clear() + if err != nil { + return errors.E(op, err) + } + + return nil + } + + return errors.E(op, errors.Errorf("no such storage: %s", in.GetStorage())) +} |