From c68be32df499fd06c2c0cc906f719586da9ee3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Sat, 26 Sep 2020 23:00:27 +0200 Subject: [PATCH] repo: split Config into 2 smaller interfaces --- repository/config.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/repository/config.go b/repository/config.go index 2133b169be47ef759fa6bfdc8f5c885e61d98444..70d51f11afaf5bfc6ab36c5f1a4e224f246ade28 100644 --- a/repository/config.go +++ b/repository/config.go @@ -13,15 +13,11 @@ var ( // Config represent the common function interacting with the repository config storage type Config interface { - // Store writes a single key/value pair in the config - StoreString(key, value string) error - - // Store writes a key and timestamp value to the config - StoreTimestamp(key string, value time.Time) error - - // Store writes a key and boolean value to the config - StoreBool(key string, value bool) error + ConfigRead + ConfigWrite +} +type ConfigRead interface { // ReadAll reads all key/value pair matching the key prefix ReadAll(keyPrefix string) (map[string]string, error) @@ -39,6 +35,17 @@ type Config interface { // Return ErrNoConfigEntry or ErrMultipleConfigEntry if // there is zero or more than one entry for this key ReadTimestamp(key string) (time.Time, error) +} + +type ConfigWrite interface { + // Store writes a single key/value pair in the config + StoreString(key, value string) error + + // Store writes a key and timestamp value to the config + StoreTimestamp(key string, value time.Time) error + + // Store writes a key and boolean value to the config + StoreBool(key string, value bool) error // RemoveAll removes all key/value pair matching the key prefix RemoveAll(keyPrefix string) error